Re: [sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-02 Thread Michael Bayer
avdd wrote: > On Feb 2, 2:52 am, "Michael Bayer" wrote: > >> the behavior you first illustrated, that of merge() and add() not acting >> the same regarding pending changes, was a behavior that was somewhat in >> the realm of a bug.   I mentioned the other day it was fixed in r6711.   > > Well no,

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-01 Thread avdd
On Feb 2, 2:52 am, "Michael Bayer" wrote: > the behavior you first illustrated, that of merge() and add() not acting > the same regarding pending changes, was a behavior that was somewhat in > the realm of a bug.   I mentioned the other day it was fixed in r6711.   Well no, not in 0.5 (r6712).

Re: [sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-01 Thread Michael Bayer
avdd wrote: > So I get around this by essentially doing: > > # called on every request > def refresh_model(context, obj): > context.get_db().add(obj) > > def store_model(context, obj): > db = object_session(obj) > if db: > db.expunge(obj) > obj = db.merge(obj) > db.flush

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-02-01 Thread avdd
So I get around this by essentially doing: # called on every request def refresh_model(context, obj): context.get_db().add(obj) def store_model(context, obj): db = object_session(obj) if db: db.expunge(obj) obj = db.merge(obj) db.flush() return obj Which seems to

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-01-30 Thread avdd
On Jan 31, 4:33 am, Michael Bayer wrote: > this example is too compliated for me to understand without great effort, > perhaps someone else has the time to follow it more closely - it appears to > be creating and closing many new sessions and add()ing objects between them - > an unusual series