]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- "delete-orphan" no longer implies "delete". ongoing effort to
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 May 2007 23:32:11 +0000 (23:32 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 May 2007 23:32:11 +0000 (23:32 +0000)
separate the behavior of these two operations.

CHANGES
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/util.py
test/orm/relationships.py

diff --git a/CHANGES b/CHANGES
index d1c0df454208fa9d702e2f2fa0db61117d8c9457..daa2e1e57ed6e2b8c8b59b14ca7956349d89c214 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
     - _Label class overrides compare_self to return its ultimate object.
       meaning, if you say someexpr.label('foo') == 5, it produces
       the correct "someexpr == 5".
+- orm
+    - "delete-orphan" no longer implies "delete". ongoing effort to 
+      separate the behavior of these two operations.
 - mysql
     - support for column-level CHARACTER SET and COLLATE declarations,
       as well as ASCII, UNICODE, NATIONAL and BINARY shorthand.
index 86c0316f221ce830fbd34f0a658c13fb2f7938ec..063d5aaa9dfd19752fb9bf51e7eb6a9a91c71a9d 100644 (file)
@@ -180,6 +180,8 @@ class OneToManyDP(DependencyProcessor):
         if delete:
             # head object is being deleted, and we manage its list of child objects
             # the child objects have to have their foreign key to the parent set to NULL
+            
+            # TODO: this cascade should be "delete" cascade
             if not self.cascade.delete_orphan or self.post_update:
                 for obj in deplist:
                     childlist = self.get_object_dependencies(obj, uowcommit, passive=self.passive_deletes)
@@ -211,6 +213,8 @@ class OneToManyDP(DependencyProcessor):
             # the child objects have to have their foreign key to the parent set to NULL
             if self.post_update:
                 pass
+            # TODO: this block based on "delete_orphan" should technically be "delete", but also
+            # is entirely not necessary
             elif self.cascade.delete_orphan:
                 for obj in deplist:
                     childlist = self.get_object_dependencies(obj, uowcommit, passive=self.passive_deletes)
index 6cb4fed6edcbb855bbb9dffbb10b14e072f2f584..923dd679770ed884df4b513ae87bc490de1aa76c 100644 (file)
@@ -15,7 +15,7 @@ class CascadeOptions(object):
     def __init__(self, arg=""):
         values = util.Set([c.strip() for c in arg.split(',')])
         self.delete_orphan = "delete-orphan" in values
-        self.delete = "delete" in values or self.delete_orphan or "all" in values
+        self.delete = "delete" in values or "all" in values
         self.save_update = "save-update" in values or "all" in values
         self.merge = "merge" in values or "all" in values
         self.expunge = "expunge" in values or "all" in values
index cc7eec915277dd5ac09c40c1e34758c413bc0e7b..6fb666dab6c86cc05fc373a988860a4224bf06b0 100644 (file)
@@ -410,7 +410,7 @@ class RelationTest4(testbase.ORMTest):
         class B(object):pass
         for cascade in (
                     "save-update, delete",
-                    "save-update, delete-orphan",
+                    #"save-update, delete-orphan",
                     "save-update, delete, delete-orphan"):
 
             mapper(B, tableB, properties={
@@ -437,7 +437,7 @@ class RelationTest4(testbase.ORMTest):
         class B(object):pass
         for cascade in (
                     "save-update, delete",
-                    "save-update, delete-orphan",
+                    #"save-update, delete-orphan",
                     "save-update, delete, delete-orphan"):
             mapper(A, tableA, properties={
                 'bs':relation(B, cascade=cascade)