Closed
Description
Migrated issue, originally created by Michael Bayer (@zzzeek)
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(create_engine('postgres://scott:tiger@127.0.0.1/test', echo=True))
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
data = Column(String)
child_id = Column(Integer, ForeignKey('child.id'))
child = relation("Child", cascade="all, delete", passive_deletes=True)
class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
data = Column(String)
Base.metadata.drop_all()
Base.metadata.create_all()
s = create_session()
p1 = Parent(data='p1', child=Child(data='c1'))
s.add(p1)
s.flush()
s.clear()
p1 = s.query(Parent).get(p1.id)
s.delete(p1)
s.flush()
the question here is, do we disable the above setting, raise a warning, or actually try to support it, since while ON DELETE CASCADE doesn't work for M2O, a trigger can be used to achieve this effect.
we might try adding a test which simulates a trigger with a ME, or uses a real trigger.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Oct 28, 2008
Michael Bayer (@zzzeek) wrote:
0719e6f
sqlalchemy-bot commentedon Oct 28, 2008
Changes by Michael Bayer (@zzzeek):