[Dbix-class] auto_increment primary key population

apv apv at sedition.com
Fri Jan 20 01:52:01 CET 2006


I accidentally sent this to Matt and he already replied but in the 
interest of the Pax DBIC, resent to the list:

On Thursday, January 19, 2006, at 03:59  PM, Matt S Trout wrote:
> On Thu, Jan 19, 2006 at 02:52:28PM -0800, apv wrote:
>> When I create/insert a new object, the primary key (an auto_increment
>> in MySQL) is not getting populated.
>> e.g.: from a set of tests I'm trying to write
>>
>> ok 26 - Inserting the user
>> # $VAR1 = bless( {
>> #                  '_dirty_columns' => {},
>> #                  '_in_storage' => 1,
>> #                  '_column_data' => {
>> #                                      'email' => 'apv at sedition.com',
>> # ...
>> #                                      'type' => 'visitor'
>> #                                    }
>> #                }, 'Ego::DB::user' );
>> # undef <<-- the result of $user->id after the insert.
>>
>> Is there some trick or something I need to do with load_components?
>> Currently looks like: __PACKAGE__->load_components(qw( Core DB ));
>
> Try adding PK::Auto::MySQL on the front of that ...


On Thursday, January 19, 2006, at 04:37  PM, Matt S Trout wrote:
> On Thu, Jan 19, 2006 at 04:19:51PM -0800, apv wrote:
>> Right you are. I sort of tried it already but didn't realize the order
>> of the components mattered.
>
> Of course; load_components faffs with your @ISA and re-complies the C3 
> MRO
> for your class if required - so order matters just as much as with 
> 'use base'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1504 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060119/75b1eb65/attachment.bin


More information about the Dbix-class mailing list