On 9/22/2010 11:21 AM, Michael Hipp wrote:
new = Car()
new.id_ = old.id_
new = sess.merge(new)
new.auction = old.auction # do this *after* merge
sess.commit()
This seems to work and ...
Bah. I spoke too soon - it just doesn't throw an exception. But without
explicitly setting every field to its default value, the session thinks nothing
has changed and the UPDATE leaves most of the fields untouched.
Anyway, it appears I need a new approach to empty/blank a record. Options I can
think of are:
1) Find a dict of all the default values for every field and set them
explicitly. Does SQLAlchemy have that somewhere?
2) What about an approach of forcing a DELETE, INSERT, COMMIT on the
old/new objects. Like this:
session.begin(subtransactions=True)
id_ = old.id_ # grab important stuff from 'old'
auct = old.auction
session.delete(old) # kill old
session.commit()
new = Car()
new.id_ = id_
new.auction = auct
new = session.merge(new)
session.commit()
But I'm worried about side effects and issues with the version_id_col.
Any thoughts appreciated...
Michael
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.