Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: cptl1234 [...] yahoo.com
Cc:
AdminCc:

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



Subject: pk not retrieved after a create
Date: Fri, 19 Oct 2012 09:41:13 -0700 (PDT)
To: bug-DBIx-Class [...] rt.cpan.org
From: Jay Calbaugh <cptl1234 [...] yahoo.com>
Hi, Problem: after a 'create', the primary key of a table is not retrieved for me. Versions: issue appears in 0.8200 and 0.8202.  Works correctly in 0.8196 Using: Red Hat, Enterprise Linux5, kernel 2.6.18-92.1.18.el5PAE, and Ubuntu 2.6.38-8-generic #42-Ubuntu DBI version: 1.612 (on Ubuntu), 1.622 (on RedHat). Perl version: 5.12.0 Using  Microsoft SQL Server 2005 - 9.00.5000.00 (X64) I've attached a very small test to duplicate this; the file 'MakeTestTable.sql' creates a very simple table to work with, and the actual test is in test_dbix.pl Thanks for a great tool, Jerry C.
Download dbix_pk_bug.tar
application/x-tar 10k

Message body not shown because it is not plain text.

On Fri Oct 19 12:41:27 2012, cptl1234@yahoo.com wrote: Show quoted text
> Hi, > > Problem: after a 'create', the primary key of a table is not retrieved > for me. > Versions: issue appears in 0.8200 and 0.8202.  Works correctly in > 0.8196
This is not entirely correct. Prior to commit fabbd5cca97 DBIC aways attempted to retrieve the PK, even if the user did not mark it a retrievable (via the is_auto_increment column info attribute). This caused massive problems in certain scenarios under certain ODBC drivers. So what you are describing as "correct" behavior was more of a problematic side-effect. If you want DBIC to retrieve identity columns, you need to declare them as such. Replace __PACKAGE__->add_columns(qw/ id name /); with __PACKAGE__->add_columns( id => { is_auto_increment => 1, data_type => int }, name => { data_type => 'varchar', size => 25, is_nullable => 1 }, ); P.S. It is *not* necessary to include the rest of the metadata - things will work to the best of their ability without such extra data. However the more you tell DBIC about your database layout, the more useful it will be. For instance by telling it that id is of the 'int' type, DBIC will correctly know that id => '5' and id => '5.00' are the same thing. Also by including the sizes and other stuff you can replace your MakeTestTable.sql with $schema->deploy, which will DTRT automatically based on the database you are connecting to. Cheers
Rejecting ticket as DBIC behaves exactly as intended. Feel free to reopen it if more questions/concerns arise.
Subject: Re: [rt.cpan.org #80283] pk not retrieved after a create
Date: Mon, 22 Oct 2012 08:02:46 -0700 (PDT)
To: bug-DBIx-Class [...] rt.cpan.org
From: Jay Calbaugh <cptl1234 [...] yahoo.com>
Thanks for taking time to clarify this for me, best, Jerry --- On Fri, 10/19/12, Peter Rabbitson via RT <bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> From: Peter Rabbitson via RT <bug-DBIx-Class@rt.cpan.org> > Subject: [rt.cpan.org #80283] pk not retrieved after a create > To: cptl1234@yahoo.com > Date: Friday, October 19, 2012, 8:17 PM > <URL: https://rt.cpan.org/Ticket/Display.html?id=80283 > > > On Fri Oct 19 12:41:27 2012, cptl1234@yahoo.com > wrote:
> > Hi, > > > > Problem: after a 'create', the primary key of a table
> is not retrieved
> > for me. > > Versions: issue appears in 0.8200 and 0.8202.  Works
> correctly in
> > 0.8196
> > This is not entirely correct. Prior to commit fabbd5cca97 > DBIC aways > attempted to retrieve the PK, even if the user did not mark > it a > retrievable (via the is_auto_increment column info > attribute). This > caused massive problems in certain scenarios under certain > ODBC drivers. > So what you are describing as "correct" behavior was more of > a > problematic side-effect. > > If you want DBIC to retrieve identity columns, you need to > declare them > as such. Replace > __PACKAGE__->add_columns(qw/ id name /); > with > __PACKAGE__->add_columns( > id => { is_auto_increment => 1, data_type => int > }, > name => { data_type => 'varchar', size => 25, > is_nullable => 1 }, > ); > > P.S. It is *not* necessary to include the rest of the > metadata - things > will work to the best of their ability without such extra > data. However > the more you tell DBIC about your database layout, the more > useful it > will be. For instance by telling it that id is of the 'int' > type, DBIC > will correctly know that id => '5' and id => '5.00' > are the same thing. > Also by including the sizes and other stuff you can replace > your > MakeTestTable.sql with $schema->deploy, which will DTRT > automatically > based on the database you are connecting to. > > Cheers >
On second though there ought to be a warning when this condition happens... Reopening for the time being.
On Mon Mar 11 04:22:05 2013, RIBASUSHI wrote: Show quoted text
> On second though there ought to be a warning when this condition > happens... Reopening for the time being.
This turned out to be even gnarlier than I originally realized, as indicated in https://rt.cpan.org/Ticket/Display.html?id=115381#txn-1638878. This is now properly addressed by https://github.com/dbsrgits/dbix-class/commit/7305f6f9 Thanks for the original report, sorry it took forever to get here.
This is finally on CPAN as https://metacpan.org/release/RIBASUSHI/DBIx-Class-0.082842 Sorry for the long road to get there.