I am using the merge() function to merge the de-serialized object into the session. I still get the error when using r5661. I'm working on putting together a test case, but I haven't been able to reproduce the problem in a simple way yet. Thank for your help.
On Jan 12, 11:18 pm, Michael Bayer <[email protected]> wrote: > I have detected the sole codepath which does in fact produce the > output you've seen which is also erroneous. That issue is fixed in > r5661. However, the reproduction of the bug is doesn't appear > possible with the scenario you describe, which suggests that your > serialization/merge scheme may still be producing data that is not > what's expected. > > The reproduction of the error is via issuing a session.delete() for > the object, then issuing session.add() for a brand new object which > has no values set in the child table, but includes the primary key of > the original object. It is not possible to produce this effect using > merge() since merge() will never result in an INSERT for a primary key > value that already exists in the database or session. > > Also, my analysis of the issue also has led me to rethink the feature > in question (called a row switch), so I will almost certainly be > changing the behavior of it once again in 0.6 to issue an explicit > DELETE and INSERT for a delete()/add() pair of the same primary key. > So if we don't figure out how your pickle/merge() scenario is being > interpreted as a delete()/add() pair, this eventual change might again > cause problems for you even if the issue is resolved for now. > > On Jan 13, 2009, at 12:03 AM, Michael Bayer wrote: > > > > > On Jan 12, 2009, at 11:37 PM, Duder wrote: > >> missing from the object, so it is generating bad SQL. Is this a bug, > >> or do I need to change something to be compatible with 0.5.0? > > > its impossible to say without a full reproducing test case. I've > > tried many versions of the test below and none have any issue: > > > from sqlalchemy import * > > from sqlalchemy.orm import * > > from sqlalchemy.ext.declarative import declarative_base > > import cPickle as pickle > > > engine = create_engine('sqlite://', echo=True) > > Base = declarative_base() > > class Person(Base): > > __tablename__ = 'people' > > id = Column('id', Integer, primary_key=True) > > name = Column('name', String(50)) > > discriminator = Column('type', String(50)) > > __mapper_args__ = {'polymorphic_on':discriminator} > > > class Engineer(Person): > > __tablename__ = 'engineers' > > __mapper_args__ = {'polymorphic_identity':'engineer'} > > id = Column('id', Integer, ForeignKey('people.id'), > > primary_key=True) > > primary_language = Column('primary_language', String(50)) > > > Base.metadata.create_all(engine) > > > e1 = Engineer(name="dilbert", primary_language="java") > > > sess = sessionmaker(engine)() > > sess.add(e1) > > > sess.commit() > > > e1 = sess.query(Person).filter(Person.name=='dilbert').one() > > > assert 'primary_language' not in e1.__dict__ > > assert 'name' in e1.__dict__ > > > sess.expunge(e1) > > > # "serialize to the client" > > e2 = pickle.loads(pickle.dumps(e1)) > > > # client changes something (?) > > e2.name = 'ed' > > > # "deserialize from the client" > > e3 = pickle.loads(pickle.dumps(e2)) > > > # merge > > e1 = sess.merge(e3) > > sess.commit() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
