On Mon, 8 Sep 2008 13:22:53 +0300 [EMAIL PROTECTED] wrote: > > maybe separate the objects to-be-saved from not-yet-to-save in your > app.code and dont leave that to SA? > do something, flush+commit, then do the rest... >
I agree, this seems like the best way to get what you want. SQL's transaction semantics don't allow for cherry-picking what you want to commit, and SA seems to reflect this atomicity in the design of Session. > flush() takes list of objects. > This might also be an option, but would require some hacks, as the subsequent commit() call would flush the whole session anyway. You'd have to come up with a way to commit the transaction without the session knowing about it :) If you go this route, be sure to review the docs on that carefully; IIRC, passing objects into flush() doesn't flush changes to any collections on the objects. I'm not sure if it will invoke cascading operations such as delete-orphan either, I tend to doubt it. On Mon, 8 Sep 2008 08:34:59 +0200 sandro dentella <[EMAIL PROTECTED]> wrote: > So the question becomes: can I disale autoflush and commit what has > already been flushed leaving the rest in the session? My test seem to > say that it's not possible. > > That leaves me with the original question: how can I just > flush/commit one single object? If you can structure your application such that the things you *do* want to commit can be saved up until the end, you can always do a manual rollback(), perform the operations what you want to save, and then commit(). Nested transactions (savepoints) may also be something to look into, such as doing operations you don't want to save in a nested transaction and then rolling it back, but committing the outer transaction (which would have what you want to keep in it). This would depend on database support for nested transactions or savepoints. Just some ideas... -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
