psychogenic wrote: > > My questions are: > > - why does the instance state think it doesn't need to insert this > object, that was never committed?
it was INSERTed in your other session. You probably didn't commit the transaction. The object then gets the "key" and such is now "persistent", until you expunge it, then its "detached". > > - SA seems to be acting as if the object is in a "Detached" state > after the expunge, even though it > was never committed and does not exist in the db. Why and can I > somehow force this to "Transient" > before the sessionB.add() or "Pending", after? blow away the key. There's a make_transient() function in 0.6 which accomplishes this but its generally "state = instance_state(obj); del state.key". the object still might have some attributes on it which you don't want, like primary key attributes that were assigned during the INSERT. You probably want to remove those too. Go through the object's attributes and ensure they all look like a row that hasn't yet been inserted. > > - why doesn't expunge remove all references to the original session/ > state -- is there a way to do this? it removes session state but doesn't remove information about the row represented. Otherwise what state should it have ? > - maybe I'm going about this completely wrong... any other method I > should be using? You probably shouldn't put things into the session that don't represent rows you'd like to see in your database - right now it seems like you're issuing needless SQL and throwing it away. > > > > > Thanks in advance and regards, > Pat Deegan > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---