summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-01-16 21:31:07 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-01-16 21:31:07 +0000
commit00df05061e7a0333022d02705c21270f9de4edab (patch)
tree47f9b344b6776398c27e4254f7b69f9077d28731
parent16ca025657714f5a031bb068effdf3c5dc15e458 (diff)
downloadsqlalchemy-00df05061e7a0333022d02705c21270f9de4edab.tar.gz
add a doc for query.delete()
-rw-r--r--doc/build/session.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/build/session.rst b/doc/build/session.rst
index da858a2ef..cbd33357b 100644
--- a/doc/build/session.rst
+++ b/doc/build/session.rst
@@ -249,6 +249,17 @@ The solution is to use proper cascading::
del user.addresses[1]
session.flush()
+Deleting based on Filter Criterion
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The caveat with ``Session.delete()`` is that you need to have an object handy already in order to delete. The Query includes a ``delete()`` method which deletes based on filtering criteria::
+
+ session.query(User).filter(User.id==7).delete()
+
+The ``Query.delete()`` method includes functionality to "expire" objects already in the session which
+match the criteria. However it does have some caveats, including that "delete" and "delete-orphan"
+cascades won't be fully expressed for collections which are already loaded. See the API docs for :meth:`~sqlalchemy.orm.query.Query.delete` for more details.
+
Flushing
--------