On Wed, Apr 30, 2008 at 9:02 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
>
>  On Apr 30, 2008, at 12:56 PM, Eric Lemoine wrote:
>
>  >
>  > thread 1                                                     thread 2
>  > execute(seq) -> nextid = n
>  >
>  > execute(seq) -> nextid = n
>  > model.Session.save(campfacility)
>  >
>  > model.Session.save(campfacility) -> BUG, nextid isn't correct
>
>  whats "correct" here, you'd like the integer identifier to be in exact
>  row-insert order ?   if the column is a non-primary key column, the
>  sequence will be executed "inline" within the executed SQL so that it
>  will in fact be in row insert order (i.e. update table set
>  foo_id=nextval(myseq)).  you can also do this at flush time by
>  assigning "func.nextval(literal_column("my_sequence_name"))" to the
>  mapped attribute (assuming its not a PK).
>
>  for primary keys we need to know the ID beforehand in most cases since
>  PG historically has not had a way to get that ID back nicely after
>  insert (it has INSERT RETURNING now but we haven't standardized on
>  that yet).

Yes, the sequence is my table's PK. What I want to know is the PK
value of the line I'm going to insert (or I've just inserted). So I
guess this is indeed INSERT RETURNING.

>  So if its a PK, I would question why you actually need an incrementing
>  id in row-insert order on the table in the first place.  Usually, if I
>  want to load records in the order in which they were inserted in a
>  foolproof way, I'll use a UTC timestamp column with an index for
>  that....since the information you are looking for here is "what was
>  inserted when?"

That's no what I want. See above. I hope it's clear enough this time.

Thanks a lot Michael,

--
Eric

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to