Skip Menu |
 

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

Report information
The Basics
Id: 32931
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: m.e [...] acm.org
Cc:
AdminCc:

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



Subject: 'Uninitialized value' when update fails
Download (untitled) / with headers
text/plain 271b
Error message: Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/site_perl/5.8.8/DBIx/Class/Row.pm line 335. I get this when I try an update that violates a UNIQUE KEY constraint. Details: MySQL 5.0.45 perl, v5.8.8 built for x86_64-linux-thread-multi
From: m.e [...] acm.org
Download (untitled) / with headers
text/plain 395b
Actually, as it happens, I was trying to overwrite the primary key (UPDATE mytable SET mykey = 0, somevalue = 'whatever' WHERE mykey = 1234;). The primary key was AUTOINCREMENT, and so declared in my schema module: __PACKAGE__->add_column( mykey => { is_auto_increment => 1 } ); but I consider this to still be a bug -- the module should do something more helpful such as throw an exception.
From: m.e [...] acm.org
Download (untitled) / with headers
text/plain 139b
The actual SQL error is: ERROR 1062 (23000): Duplicate entry '0' for key 1 so it is still a duplicate key error, though on the primary key.
Subject: Re: [rt.cpan.org #32931] 'Uninitialized value' when update fails
Date: Tue, 5 Feb 2008 08:46:30 +0000
To: Martin via RT <bug-DBIx-Class [...] rt.cpan.org>
From: Matt S Trout <mst [...] shadowcatsystems.co.uk>
Download (untitled) / with headers
text/plain 869b
On Tue, Feb 05, 2008 at 12:47:02AM -0500, Martin via RT wrote: Show quoted text
> > Queue: DBIx-Class > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=32931 > > > The actual SQL error is: > ERROR 1062 (23000): Duplicate entry '0' for key 1 > so it is still a duplicate key error, though on the primary key.
If you write a standalone test script, do you still get the uninit warning? Since we set RaiseError to 1 on the dbh I'd expect an exception to be thrown. Do you have anything like Catalyst::Plugin::StackTrace loaded that sets a SIGDIE handler? -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
From: m.e [...] acm.org
I have created a test case but that works fine. I will need to investigate further.
Download MyTable.pm
text/x-perl 316b
use strict; use warnings; package DB::Main::MyTable; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('mytable'); __PACKAGE__->add_columns(qw/something altkey/); __PACKAGE__->add_column( mykey => { is_auto_increment => 1 } ); __PACKAGE__->set_primary_key('mykey'); 1;
Download mk-db.sql
text/x-sql 568b
DROP DATABASE IF EXISTS testdbix; CREATE DATABASE testdbix; USE testdbix; CREATE TABLE mytable ( mykey SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, something VARCHAR(16) NOT NULL DEFAULT '???', altkey SMALLINT UNSIGNED NOT NULL, PRIMARY KEY (mykey), UNIQUE KEY altkey (altkey) ); INSERT into mytable SET something = 'alpha', altkey = 10; INSERT into mytable SET something = 'beta', altkey = 11; INSERT into mytable SET something = 'gamma', altkey = 12; SELECT * FROM mytable; UPDATE mytable SET altkey = 10 WHERE mykey = 2;
Download case.pl
text/x-perl 782b
#!/usr/bin/perl use strict; use warnings; use DB::Main; my ( $dbi_dsn, $user, $pass ) = ( q{dbi:mysql:testdbix}, q{root}, q{} ); my $schema = DB::Main->connect( $dbi_dsn, $user, $pass, {} ); my @rows = $schema->resultset(q{MyTable})->all; for my $r (@rows) { print join( q{/}, $r->mykey, $r->something, $r->altkey ), qq{\n}; } print qq{case 1\n}; eval { $schema->resultset(q{MyTable})->search({mykey=> 2})->update( { altkey => 10 } ); print qq{update done\n}; }; if ($@) { print qq{exception: $@\n}; } else { print qq{no exception}; } print qq{case 2\n}; eval { $schema->resultset(q{MyTable})->search({mykey=> 2})->update( { mykey => 1 } ); print qq{update done\n}; }; if ($@) { print qq{exception: $@\n}; } else { print qq{no exception}; }
Download Main.pm
text/x-perl 114b
use strict; use warnings; package DB::Main; use base qw/DBIx::Class::Schema/; __PACKAGE__->load_classes(); 1;
Subject: Re: [rt.cpan.org #32931] 'Uninitialized value' when update fails
Date: Wed, 6 Feb 2008 16:44:49 +0800
To: bug-DBIx-Class [...] rt.cpan.org
From: "Martin Ellison" <m.e [...] acm.org>
Download (untitled) / with headers
text/plain 1.3k
I've done a test case and everything works fine there, so I'm not sure then what the problem was with my program. It's New Year here so I am not sure whether I will have time in the next few days to investigate further. On 05/02/2008, Matt S Trout via RT <bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> > > <URL: http://rt.cpan.org/Ticket/Display.html?id=32931 > > > On Tue, Feb 05, 2008 at 12:47:02AM -0500, Martin via RT wrote:
> > > > Queue: DBIx-Class > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=32931 > > > > > The actual SQL error is: > > ERROR 1062 (23000): Duplicate entry '0' for key 1 > > so it is still a duplicate key error, though on the primary key.
> > If you write a standalone test script, do you still get the uninit > warning? > > Since we set RaiseError to 1 on the dbh I'd expect an exception to be > thrown. > > Do you have anything like Catalyst::Plugin::StackTrace loaded that sets a > SIGDIE handler? > > -- > Matt S Trout Need help with your Catalyst or DBIx::Class > project? > Technical Director > http://www.shadowcat.co.uk/catalyst/ > Shadowcat Systems Ltd. Want a managed development or deployment platform? > http://chainsawblues.vox.com/ > http://www.shadowcat.co.uk/servers/ > >
-- Regards, Martin (m.e@acm.org) IT: http://methodsupport.com Personal: http://thereisnoend.org
Subject: Re: [rt.cpan.org #32931] 'Uninitialized value' when update fails
Date: Sat, 9 Feb 2008 13:08:13 +0000
To: Martin via RT <bug-DBIx-Class [...] rt.cpan.org>
From: Matt S Trout <dbix-class [...] trout.me.uk>
Download (untitled) / with headers
text/plain 797b
On Fri, Feb 08, 2008 at 01:42:28PM -0500, Martin via RT wrote: Show quoted text
> > Queue: DBIx-Class > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=32931 > > > I've done a test case and everything works fine there, so I'm not sure then > what the problem was with my program. It's New Year here so I am not sure > whether I will have time in the next few days to investigate further.
I'd bet on something eating the exception. Gimme a shout if you can reproduce it otherwise3. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
Download (untitled) / with headers
text/plain 147b
Since it's been three months, I'm going to assume it was working fine after all. Please reply to re-open the ticket if you do get a test together.


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.