track objects that had any flush state for the lifespan of transaction scope similarly to self._new, self._deleted, take advantage of this for savepoint rollbacks
No description provided.
Comments (6)
-
reporter -
Account Deleted (original author: werner) Michael,
My initial tests with this patch applied to 0.7.6 look very good.
Will keep watching this and let you know should I run into anything.
Thanks Werner
-
reporter unfortunately this patch fails very easily as "dirty" has nothing to do with objects that were already flushed:
from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base= declarative_base() class A(Base): __tablename__ = "a" id = Column(Integer, primary_key=True) data = Column(String(50)) e = create_engine("postgresql://scott:tiger@localhost/test") Base.metadata.drop_all(e) Base.metadata.create_all(e) s = Session(e) a1, a2, a3 = A(data='a1'), A(data='a2'), A(data='a3') s.add_all([a2, a3](a1,)) s.commit() a1 = s.query(A).filter_by(data='a1').one() s.begin_nested() a1.data = 'a1modified' a2 = s.query(A).filter_by(data='a2').one() a3 = s.query(A).filter_by(data='a3').one() s.rollback() assert a1.data == 'a1', "%s != %s" % (a1.data, 'a1')
the approach is not feasible as we can't store the full state of all flushed objects in memory. They have to be loaded from the database, which is the only place the data is present. So for this to work, every object in the Session which was affected in the flush needs to be added to a new transaction collection called ._dirty or ._flushed, which will indicate those objects that had changes.
-
reporter -
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.8.0b1 (automated comment)
- Log in to comment