>-----Message d'origine-----
>De : dbix-da...@googlegroups.com [mailto:dbix-
>data...@googlegroups.com] De la part de jfraire
>Envoyé : jeudi, 23. septembre 2010 10:09
>À : dbix-datamodel
>Objet : [dbix-datamodel] PostgreSQL, serial data types and
>last_insert_id
>
>Hello Laurent!
>
>First off, congratulations for your fantastic ORM. I found it very
>usable and easy to understand. A big thank you. I use it with
>PostgreSQL and I love it.
Thanks, I'm always happy to hear from users. If you could find some time to repeat your appreciation as a report in cpanratings.perl.org, that would help DBIx::DataModel to become more well-known. Or write a blog entry explaining why you chose DBIxDM instead of DBIx::Class. DBIxDM is in great need of some publicity !
>
>So, would you please change the third and fourth undefs for $table,
>$col? You are already using them in the third option. I guess $col is
>the primary key of the table:
>
> # or plain call to last_insert_id() with all undefs
> : $dbh->last_insert_id(undef, undef, $table, $col);
Actually, I had something like this in a previous version ... but then some drivers didn't like getting $table and $col arguments without a schema or catalog! So this is why I reverted to passing all undefs, which is somehow the "standard default" defined by DBI. If this is not convenient, there are some options to tune it, as you already discovered.
>
>I fixed my problem by doing this:
>My::Schema->dbh( $dbh, schema => 'public');
>by which I got the second option to look like this:
> $dbh->last_insert_id(undef, 'public', $table, $col);
Good, the "schema" or "catalog" options were especially meant for that kind of usage, so I'm happy if it works. Another way would be to write your own last_id handler, like this :
My::Schema->dbh($dbh, last_insert_id => sub {
my ($dbh, $table, $col) = @_;
$dbh->last_insert_id(undef, 'public', $table, $col); # or whatever code you like
});
Best regards,
Laurent Dami