Skip to content

odd passive_deletes setting raises #1183

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

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.

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Oct 28, 2008

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

0719e6f

sqlalchemy-bot

sqlalchemy-bot commented on Oct 28, 2008

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added this to the 0.5.0 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingorm

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          odd passive_deletes setting raises · Issue #1183 · sqlalchemy/sqlalchemy