Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 57379
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: christian.koetschan [...] googlemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



From christian.koetschan [...] googlemail.com Tue May 11 12: 16:59 2010
MIME-Version: 1.0
X-Spam-Status: No, score=-9.912 tagged_above=-99.9 required=10 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-8, SPF_NEUTRAL=0.686] autolearn=ham
X-Spam-Flag: NO
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Content-Type: multipart/alternative; boundary=0016e6d9a3aca7911d048653db1a
Message-ID: <AANLkTinY-PEJXbhWxk4iqpN_fDlXCKXsQA1cu7dAqBY1 [...] mail.gmail.com>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -9.912
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 47E05240724 for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Tue, 11 May 2010 12:16:59 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DPtXohtiwUgR for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Tue, 11 May 2010 12:16:57 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 327472406D9 for <bug-DBIx-Class [...] rt.cpan.org>; Tue, 11 May 2010 12:16:57 -0400 (EDT)
Received: (qmail 32102 invoked by uid 103); 11 May 2010 16:17:20 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 11 May 2010 16:17:20 -0000
Received: from mail-wy0-f178.google.com (HELO mail-wy0-f178.google.com) (74.125.82.178) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 11 May 2010 09:17:15 -0700
Received: by wyb40 with SMTP id 40so942395wyb.9 for <bug-DBIx-Class [...] rt.cpan.org>; Tue, 11 May 2010 09:17:12 -0700 (PDT)
Received: by 10.216.89.194 with SMTP id c44mr3685069wef.40.1273594632441; Tue, 11 May 2010 09:17:12 -0700 (PDT)
Received: by 10.216.164.17 with HTTP; Tue, 11 May 2010 09:17:12 -0700 (PDT)
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] googlemail.com
Authentication-Results: hipster.bestpractical.com (amavisd-new); domainkeys=pass header.from=christian.koetschan [...] googlemail.com
Delivered-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
Subject: DBIx-Class-0.08121 - update_all uses wrong value for primary key in WHERE clause
Return-Path: <christian.koetschan [...] googlemail.com>
Domainkey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=mZNEDFNTkbkjbQv3ckfarpPIuCKzMwS54dKWOwyRuZH934X+RlVN2JDu4OVY4CKYtQ skw7y8QM2FlL8Zv/8x5TUDXKwV4sBnD8mjZ8BVllW9iDmRkNtrZj+BYnnyURwQ2T0tAx sgB7id6uv3A7RZd575chbUGL7oHEBYxcF0MUI=
X-RT-Mail-Extension: dbix-class
X-Original-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=ePXFXsh3aE9vo9jcvdNUu1gCVeNK8EPwnK/j/OgJWaM=; b=mPV49uwDZc+OQBxROiGLr6cAp3y6MzXYkOrvSrefDSVeHiikAbPH1ouUrYQP5cIqFZ 9IGlDCct6FNeeipGk8ulMwgH9M3DDA5WKVpjU52nb8Y+L8DTt5A5nqHaIF0SL7v5LbCi 8cR9Dyjw2HJtM4bK451oCqqoOuRr2QDUMlR8E=
Date: Tue, 11 May 2010 18:17:12 +0200
X-Spam-Level:
To: bug-DBIx-Class [...] rt.cpan.org
From: Christian Koetschan <christian.koetschan [...] googlemail.com>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 1021
Download (untitled) / with headers
text/plain 1021b
Hi, I'm using update_all in a Catalyst/Postgres environment from DBIx-Class-0.08121.tar.gz on a x86_64 GNU/Linux. The following hashreference is passed to update_all(): [debug] $VAR1 = { 'magazine' => 'Magazine TEST', 'pubdate' => '2010-04-21T00:00:00', 'id' => 18 }; The resulting error: ( I executed "my $success = $c->model('DBModel::Pressrelease')->update_all($c->request->data->{jsonresponse});") [error] DBIx::Class::ResultSet::update_all(): DBI Exception: DBD::Pg::st execute failed: ERROR: duplicate key violates unique constraint "pressreleases_pkey" [for Statement "UPDATE pressreleases SET id =?, magazine = ?, pubdate = ? WHERE ( id = ? )" with ParamValues: 1='18', 2='Magazine TEST', 3='2010-04-21T00:00:00', 4='10'] The Problem in the generated SQL statement is that ParamValue 4 (the one in the WHERE clause) is 10 and not 18. I have no clue where this 10 is coming from. My primary key is set to "id", and the structure of the statement looks correct to me.
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 1269
MIME-Version: 1.0
In-Reply-To: <AANLkTinY-PEJXbhWxk4iqpN_fDlXCKXsQA1cu7dAqBY1 [...] mail.gmail.com>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <AANLkTinY-PEJXbhWxk4iqpN_fDlXCKXsQA1cu7dAqBY1 [...] mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-6782-1273654256-715.57379-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1869
Download (untitled) / with headers
text/plain 1.8k
On Tue May 11 12:17:27 2010, christian.koetschan@googlemail.com wrote: Show quoted text
> Hi, > > I'm using update_all in a Catalyst/Postgres environment from > DBIx-Class-0.08121.tar.gz on a x86_64 GNU/Linux. > > The following hashreference is passed to update_all(): > > [debug] $VAR1 = { > 'magazine' => 'Magazine TEST', > 'pubdate' => '2010-04-21T00:00:00', > 'id' => 18 > }; > > > The resulting error: > ( I executed "my $success = > $c->model('DBModel::Pressrelease')->update_all($c->request->data-
> >{jsonresponse});")
> > [error] DBIx::Class::ResultSet::update_all(): DBI Exception: > DBD::Pg::st > execute failed: ERROR: duplicate key violates unique constraint > "pressreleases_pkey" [for Statement "UPDATE pressreleases SET id =?, > magazine = ?, pubdate = ? WHERE ( id = ? )" with ParamValues: 1='18', > 2='Magazine TEST', 3='2010-04-21T00:00:00', 4='10'] > > > The Problem in the generated SQL statement is that ParamValue 4 (the > one in > the WHERE clause) is 10 and not 18. I have no clue where this 10 is > coming > from. My primary key is set to "id", and the structure of the > statement > looks correct to me.
From the docs: 'Fetches all objects and updates them one at a time.' So your snippet is equivalent to: my $rs = $c->model('DBModel::Pressrelease'); while (my $x = $rs->next) { $x->update($c->request->data->{jsonresponse}) } Therefore I'm guessing that the id = 10 is coming from the existing values of the primary key column from an existing row. In other words, using update_all and passing in a primary key to update doesn't make a huge amount of sense as it will try to set all rows to the same primary key. I think this is a case of using the wrong method - you probably want search + update instead. I'm closing this ticket, feel free to reopen it with more details if there is still a problem


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.