Thanks a lot, this is what I was hoping for!
Anders

On 11/2/21 9:33 PM, Mike Bayer wrote:
The answers regarding "cascade" are correct, however this question has been asked a few times before and we have a recipe on the Wiki that discusses this problem and presents an ORM event oriented solution, which is at https://github.com/sqlalchemy/sqlalchemy/wiki/ManyToManyOrphan , which I put up after answering this question on stackoverflow a few times.   It also seems to state that SQLAlchemy-utils includes such a feature, which is probably based on this recipe, that's at https://sqlalchemy-utils.readthedocs.io/en/latest/listeners.html#many-to-many-orphan-deletion and maybe that works too.

this is kind of old-ish stuff so i haven't tested it recently to see if things are up to date but the basic idea should still be working.



On Tue, Nov 2, 2021, at 4:49 PM, Anders Buch wrote:
Hello All,

Suppose I have a table of people, a table of secrets, and a many-to-many association table between them. A person can exist without knowing any secrets, but a secret without any associated people might as well be deleted. My reading of the documentation is that it is not possible to set cascade options to obtain this behavior? (Because a cascade delete option would cause a secret to be deleted if any person forgets about it?) If correct, is there another elegant way to achieve this?

Thanks in advance!
Anders Buch


--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com.

--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
http://www.sqlalchemy.org/
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/t5XRcSJSdw8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/328beb56-2edf-417d-8593-1fb277a81929%40www.fastmail.com.

--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
http://www.sqlalchemy.org/
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/f3da02c4-effd-2248-4ef6-c0e04776dd91%40gmail.com.

Reply via email to