Aight, thanks for the explanation!
Koen
On Nov 20, 5:02 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Nov 20, 2007, at 6:19 AM, Koen Bok wrote:
>
>
>
> > I have some questions about pickling/merging objects.
>
> > I have written example code to demonstrate:http://pastie.caboo.se/120146
>
> > Kindest regards,
>
> OK ive rewritten that error message in r3809 since it made no sense.
> now it will say:
>
> Could not update instance '[EMAIL PROTECTED]', identity key ( '__main__.User'>, (1,), None); a different instance with the same
> identity key already exists in this session.
>
> the error is that you need to use the return value of merge:
>
> user1 = Session.merge(user1, dont_load=True)
>
> as for the "dirty" list, i think we might need to put a more friendly
> "dirty" accessor on there (or a note in the docs)...the merge process
> sets attributes in the normal way so that things like backrefs fire
> off, but a side effect is that its flipping on the "modified" flag on
> every object. the "modified" flag is just a cue to add the object to
> the flush process, but if nothing actually changed on it then it wont
> be updated.
>
> A more expensive check, i.e. comparing the attribute values on the
> instances, would reveal that they arent "dirty" after all, and this is
> the check that happens during flush.
>
> we cant *really* preserve the modified flag here from merged to
> already-present, since if A1.foo == "ed", and A2.foo == "jack", both
> have no "modified" flag, but then you merge A2 on top of A1, A1 *is*
> actually modified.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---