add per-mapper dependencies even if no detected state change on relationship
Issue #2002
resolved
########
# randomize sets
from sqlalchemy.orm import unitofwork, session, mapper, dependency
from sqlalchemy import topological
from sqlalchemy.test.util import RandomSet
topological.set = unitofwork.set = session.set = mapper.set = dependency.set = RandomSet
##########
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, Session
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.types import Integer
engine = create_engine('postgresql://scott:tiger@localhost/test', echo=True)
Model = declarative_base()
class Parent(Model):
__tablename__ = 'parents'
id = Column(Integer, primary_key=True)
class Child(Model):
__tablename__ = 'children'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, ForeignKey('parents.id'),
nullable=False)
parent = relationship('Parent')
Model.metadata.create_all(engine)
parent = Parent()
children = [Child(parent=parent)](Child(parent=parent),)
session = Session(engine)
try:
session.add_all(children)
session.add(parent)
session.commit()
for child in children:
session.delete(child)
session.delete(parent)
session.commit()
finally:
Model.metadata.drop_all(engine)
Comments (3)
-
reporter -
reporter - changed status to resolved
12f75f29baf02d081db86ddf2cd976970f62945e 80ae02f7dc3ddc78cbdccd41ddfd3515f980c9ee (the changelog message has the wrong rev)
-
reporter - removed milestone
Removing milestone: 0.6.6 (automated comment)
- Log in to comment
potential patch. leave it up to "passive_deletes" as always:
this approach maintains the unit tests including the ones that test the size of the uow. It also handles the self referential case.