[Dbix-class] auto_increment primary key population

Michele Beltrame mb at italpro.net
Thu Mar 23 15:43:18 CET 2006


Hello!

I reply to a message which is quite old, but the topic is interesting.

>         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
>
>         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 ...

I'm doing this way as well. However, I was wondering if there is a way
to automatically do this without making it explicit for every table
schema class to load PK::Auto::MySQL component. Would it be possible for
DBIx::Class to auto-detect this if the connection dsn is MySQL-related?

I'm not asking this because I'm too lazy to write that string in all my
classes (well, also for that ;-)), but because this would help if one
needs to deploy the same code on MySQL and - say - Postgres environments.

Thanks,
Michele.

-- 
Michele Beltrame
http://www.varlogarthas.net/
ICQ# 76660101
Informativa privacy: http://www.italpro.net/em.html



More information about the Dbix-class mailing list