summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-09-12 18:17:18 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-09-12 18:17:18 -0400
commit2cd53196ea2df7b9006dcc48fb79555eb533f5cc (patch)
treec7cbb4708c42578b0094f0797324d8b21252cdfa
parentce62fa2eed1d93c9b6e383e48dcfaf5380b86915 (diff)
downloadsqlalchemy-2cd53196ea2df7b9006dcc48fb79555eb533f5cc.tar.gz
- add caveat for bulk deletes that they are generally not feasible
for joined inheritance Change-Id: I043a5842401d586aa3ff96d05e06b443ff03fa60
-rw-r--r--lib/sqlalchemy/orm/query.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 592c685ca..f74fd44bb 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -3073,6 +3073,32 @@ class Query(object):
.. warning:: **Additional Caveats for bulk query deletes**
+ * This method does **not work for joined
+ inheritance mappings**, since the **multiple table
+ deletes are not supported by SQL** as well as that the
+ **join condition of an inheritance mapper is not
+ automatically rendered**. Care must be taken in any
+ multiple-table delete to first accomodate via some other means
+ how the related table will be deleted, as well as to
+ explicitly include the joining
+ condition between those tables, even in mappings where
+ this is normally automatic. E.g. if a class ``Engineer``
+ subclasses ``Employee``, a DELETE against the ``Employee``
+ table would look like::
+
+ session.query(Engineer).\\
+ filter(Engineer.id == Employee.id).\\
+ filter(Employee.name == 'dilbert').\\
+ delete()
+
+ However the above SQL will not delete from the Engineer table,
+ unless an ON DELETE CASCADE rule is established in the database
+ to handle it.
+
+ Short story, **do not use this method for joined inheritance
+ mappings unless you have taken the additional steps to make
+ this feasible**.
+
* The method does **not** offer in-Python cascading of
relationships - it is assumed that ON DELETE CASCADE/SET
NULL/etc. is configured for any foreign key references