Tvrtko wrote:
>
> Hi,
>
> is it possible to merge an object back to session, but without merging
> the entire tree of related objects. Just this one root object.

the general way is to disable merge cascade on the relation(), using
"cascade='save-update'" or "cascade=None"

> I created a new user instance and copied all relevant attributes to
> it. I then tried to merge this copy back to session, but it doesn't
> work because you can only merge detached objects not transient ones

transient objects can be merged.  They get added to the session and enter
the pending state.

> I then tried removing related objects but I'm not even sure how to do
> that. Anyway, the problem here is that you can't merge dirty objects.

dirty objects are also mergeable, but only if you allow the Session to
load their existing state from the database (i.e. you dont use the
'dont_load' flag).   If you're playing with caching you shouldn't put
dirty objects into a cache.

>
> My version of sqlalchemy is 0.4.4

oof.   go to 0.4.8 at the very least.   0.5.6 preferably.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to