Le 2012-08-14 à 02:07, Christian MICHON a écrit :

> Hi Jeremy,
> 
> On Sun, Aug 12, 2012 at 2:39 PM, Christian MICHON
> <[email protected]> wrote:
> 
> One problem though: using this code, my saved Human object 'Bobby'
> gets its id = 2, because 1st save did not work: is this the expected
> behavior?

On PostgreSQL, sequences are not subject to transaction commit/rollback. This 
is to prevent race conditions.  Notice the following:

# create sequence myseq; select nextval('myseq'); begin; select 
nextval('myseq'); rollback; select nextval('myseq');
CREATE SEQUENCE
 nextval 
---------
       1
(1 row)

BEGIN
 nextval 
---------
       2
(1 row)

ROLLBACK
 nextval 
---------
       3
(1 row)

After the ROLLBACK, the next value is 3, instead of 2 if the rollback had 
happened.

I suspect the same thing happens on H2: Sequel runs INSERT INTO humans(...) 
VALUES (...), which requests the next value for the sequence, and since 
sequences aren't rolled back, then the next value after that has the gap.

Hope that helps!
François Beausoleil

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to