[Dbix-class] postgresql and serial primary key

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Feb 2 19:20:32 GMT 2015


On 02/02/2015 06:02 PM, Luca Ferrari wrote:
> ...
>
> my $current_ticket = $c->model( 'DB::Ticket' )->find_or_new( { pk => $pk } );
> ...
> $current_ticket->update_or_insert();
>
> the problem is that for a new record the pk field is still null, and
> therefore the sequence is not called since the value NULL is placed in
> the query.

I do not entirely understand what is the sequence of events - you 
omitted the stuff between find_or_new and update_or_insert. What are you 
doing inbetween?

And a little speculation which maybe will front-run the question: new() 
will never query the sequence to retrieve a value. This will only happen 
on insert().

If this is what you are already expecting and it isn't happening - 
please elaborate further on what is the exact sequence of events plus 
the corresponding DBIC_TRACE=1




More information about the DBIx-Class mailing list