[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:

http://scm.codesynthesis.com/?p=odb/libodb-pgsql.git;a=commit;h=f3e83073310e5fbafb142bb8d3cd1b03ed6088e9
http://scm.codesynthesis.com/?p=odb/odb.git;a=commit;h=1e5d1211d09c1f50921aa45d8c776be3758a6d89

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

Thanks for reporting this and suggesting the fix!

Boris



More information about the odb-users mailing list