On Dec 21, 2007, at 3:54 PM, Anton V. Belyaev wrote: > > merge worked without an exception this time.
merge is working rudimentally for objects with unloaded scalar/ instance/collection attributes in r3974. whats not yet happening is the merging of the various query.options() that may be present on the original deferred loader, which means the merged instance wont necessarily maintain the exact eager/lazy/deferred loading of the original, but this is not especially critical for the basic idea to work. example script using merge attached. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
from sqlalchemy import * from sqlalchemy.orm import * import pickle engine = create_engine('sqlite://', echo=True) metadata = MetaData(engine) users = Table('users', metadata, Column('id', Integer, primary_key=True), Column('name', String(30), nullable=False)) users.create() class User(object): pass mapper(User, users, properties={ 'name':deferred(users.c.name) }) u1 = User() u1.name = 'ed' sess = create_session() sess.save(u1) sess.flush() sess.clear() u2 = sess.query(User).get(u1.id) assert 'name' not in u2.__dict__ u3 = pickle.loads(pickle.dumps(u2)) sess2 = create_session() u3 = sess2.merge(u3, dont_load=True) assert 'name' not in u3.__dict__ assert u3.name == 'ed'