[Dbix-class] possible bug in DBIC:ResultSet?

Jess Robinson castaway at desert-island.demon.co.uk
Wed Jun 7 17:38:39 CEST 2006


Umm, not sure I understand the restated problem, but if your DB is 
auto-filling fields and you want to retrieve them into your row object, 
you want to either:
write your own component thath overloads insert, just like PK::Auto does, 
for those fields
or:
Call ->discard_changes on your object, after inserting it, which will 
update it with values in the DB.

Jes


On Tue, 6 Jun 2006, Mark Hedges wrote:

>
> That wasn't actually the problem, sorry.
>
> On Tue, 6 Jun 2006, Mark Hedges wrote:
>>
>>     DBIx::Class::ResultSet::create(): Can't get last insert id
>>     at (script) line 93
>>     Stack:
>>     [/usr/share/perl5/Carp/Clan.pm:214]
>>     [/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm:692]
>>     [/usr/local/share/perl/5.8.8/DBIx/Class/Row.pm:408]
>>     [/usr/local/share/perl/5.8.8/DBIx/Class/PK/Auto.pm:53]
>>     [/usr/local/share/perl/5.8.8/DBIx/Class/ResultSet.pm:1054]
>>     [(script):93]
>>     [...]
>
> I didn't look closely.  This is another entity that has a
> timestamp DEFAULT CURRENT_TIMESTAMP() as a column of an MCPK.
>
> I tried adding
>
>  __PACKAGE__->load_components(qw( PK::Auto Core ));
>
> to the class package for this entity.  It doesn't help.  Same error.
>
> Probably because last_insert_id() is looking for an
> auto-increment value and doesn't know anything about timestamps.
>
> I'm going to fake this one using a DateTime->now from the
> script instead of trying to use the MySQL server's NOW().
>
> Mark
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
>
>



More information about the Dbix-class mailing list