[odb-users] Re: lastval as primary key of the newly inserted entity returns wrong value

Boris Kolpackov boris at codesynthesis.com
Fri Oct 28 05:24:31 EDT 2011

Hi Konstantin,

Konstantin Mikhailov <ekimka at gmail.com> writes:

> So, after digging a sources we invent a quick workaround (please note --
> we're using the 'id' of type bigint in all our tables as primary key - 
> so the returning clause is hardcoded).

Yes, the RETURNING clause is probably the best way to solve this. We are
already using this technique for the upcoming Oracle support which doesn't
have anything like lastval.

So I went ahead and implemented it for PostgreSQL as well. If you are
interested, the changes are here:


This fix will appear in the upcoming 1.7.0. We are also planning to make a
pre-release in the next week or two, so you can test it there if you would

Thanks for reporting this and suggesting the fix!


More information about the odb-users mailing list