]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update delete-orphan cascade docs per [ticket:2332]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Dec 2011 17:15:06 +0000 (12:15 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Dec 2011 17:15:06 +0000 (12:15 -0500)
doc/build/orm/session.rst
lib/sqlalchemy/orm/__init__.py

index 1e77a2cecd8fa0e786e2adfb2999fa1883d0ce90..a41d514f2b8e05892cb06a44f7108ec20cdc1b84 100644 (file)
@@ -523,8 +523,8 @@ is extremely convenient.  The solution here would usually be to not assign
 ``a1.user`` to an object already persistent in the target
 session.
 
-Note that a new :func:`.relationship` option introduced in 0.6.5, 
-``cascade_backrefs=False``, will also prevent the ``Address`` from
+The ``cascade_backrefs=False`` option of :func:`.relationship`
+will also prevent the ``Address`` from
 being added to the session via the ``a1.user = u1`` assignment.
 
 Further detail on cascade operation is at :ref:`unitofwork_cascades`.
@@ -942,7 +942,7 @@ is already present in a session will also be added to that same session.
 relationship()-based attribute, meaning that objects which were removed from a
 scalar or collection attribute whose changes have not yet been flushed are
 also placed into the new session - this so that foreign key clear operations
-and deletions will take place (new in 0.6).
+and deletions will take place.
 
 Note that the ``delete-orphan`` cascade only functions for relationships where
 the target object can have a single parent at a time, meaning it is only
@@ -957,7 +957,10 @@ objects to allow attachment to only one parent at a time.
 The default value for ``cascade`` on :func:`~sqlalchemy.orm.relationship` is
 ``save-update, merge``.
 
-``save-update`` cascade also takes place on backrefs by default.   This means
+Controlling Cascade on Backrefs
+-------------------------------
+
+The ``save-update`` cascade takes place on backrefs by default.   This means
 that, given a mapping such as this::
 
     mapper(Order, order_table, properties={
@@ -981,7 +984,7 @@ place::
     >>> i1 in session
     True
 
-This behavior can be disabled as of 0.6.5 using the ``cascade_backrefs`` flag::
+This behavior can be disabled using the ``cascade_backrefs`` flag::
 
     mapper(Order, order_table, properties={
         'items' : relationship(Item, backref='order', 
index ec4f39fdf86b735e245ad93be82eabcdbeccc1c5..afb64d491880199792a9615a40831b5c8878023c 100644 (file)
@@ -295,10 +295,13 @@ def relationship(argument, secondary=None, **kwargs):
       * ``delete`` - cascade the :meth:`.Session.delete`
         operation
 
-      * ``delete-orphan`` - if an item of the child's type with no
-        parent is detected, mark it for deletion.  Note that this
-        option prevents a pending item of the child's class from being
-        persisted without a parent present.
+      * ``delete-orphan`` - if an item of the child's type is 
+        detached from its parent, mark it for deletion.  
+        As of version 0.7, this option does not prevent
+        a new instance of the child object from being persisted
+        without a parent to start with; to constrain against
+        that case, ensure the child's foreign key column(s)
+        is configured as NOT NULL
 
       * ``refresh-expire`` - cascade the :meth:`.Session.expire` 
         and :meth:`~sqlalchemy.orm.session.Session.refresh` operations
@@ -306,6 +309,9 @@ def relationship(argument, secondary=None, **kwargs):
       * ``all`` - shorthand for "save-update,merge, refresh-expire,
         expunge, delete"
 
+     See the section :ref:`unitofwork_cascades` for more background
+     on configuring cascades.
+     
     :param cascade_backrefs=True:
       a boolean value indicating if the ``save-update`` cascade should
       operate along an assignment event intercepted by a backref.   
@@ -332,7 +338,8 @@ def relationship(argument, secondary=None, **kwargs):
                 )
         })
       
-      ``cascade_backrefs`` is new in 0.6.5.
+      See the section :ref:`unitofwork_cascades` for more background
+      on configuring cascades.
 
     :param collection_class:
       a class or callable that returns a new list-holding object. will