Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-18 Thread Mike Bayer
mary_key=True, >>>> default=uuid4()) >>>> children = relationship( >>>> "ChildClass", >>>> secondary="mix_parent_class_child_class", >>>> cascade="all, delete", >>>>

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-18 Thread Mark Aquino
: Thursday, December 17, 2020 9:32:40 PM To: noreply-spamdigest via sqlalchemy Subject: Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic perhaps you are looking to set viewonly=True on this second relationship? that will exclude it from

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread Mike Bayer
id", >>> ForeignKey("parent_class.id", ondelete="CASCADE"), >>> nullable=False, >>> ), >>> Column("child_class_id", ForeignKey("child_class.id"), nullable=False), >>> UniqueCo

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread maqui...@gmail.com
t;parent_class_id", >> "child_class_id", >> name="uix_parent_class_child_class", >> ), >> ) >> >> mix_child_class_child_child_class = Table( >> "mix_child_class_child_child_class", >>

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread maqui...@gmail.com
"child_child_class_id", > ForeignKey("child_child_class.id"), > nullable=False, > ), > UniqueConstraint( > "child_class_id", > "child_child_class_id", > name="uix_child_class_child_child_class", >

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread Mike Bayer
or all SubClassXs that could be > filtered to whatever subclass you need. All these relationships use the same > mixer table, because they all share a primary key with BaseClass (and > removing the need to make explicit mixed tables for every subclass). > > Mark Aquino > >

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread Mark Aquino
To: noreply-spamdigest via sqlalchemy Subject: Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic your examples aren't complete or runnable so I don't really know what the issue is, although having two relationships to the same target

Re: [sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread Mike Bayer
your examples aren't complete or runnable so I don't really know what the issue is, although having two relationships to the same target class seems a little unusual and I'm not sure why you'd need that. On Thu, Dec 17, 2020, at 6:01 PM, maqui...@gmail.com wrote: > > I think I may have just

[sqlalchemy] Re: Can't delete cascade many-to-many with polymorphic relationships unless using lazy=dynamic

2020-12-17 Thread maqui...@gmail.com
I think I may have just found a solution? Not sure if this is correct but it looks like it worked when i changed the "extra" relationship to passive_deletes=True instead of cascade class ChildClass(XPressoBase): __tablename__ = "child_class" id = Column("id", UUID(as_uuid=True),