summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-05-03 23:32:11 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-05-03 23:32:11 +0000
commit591b1d975b4d9469b56a9621c0863b2edd2a5b32 (patch)
treec054323321e0690c7512db3627b72281fb4bc453
parent752ef2802c57d32fe832b76b9503f42f0300da05 (diff)
downloadsqlalchemy-591b1d975b4d9469b56a9621c0863b2edd2a5b32.tar.gz
- "delete-orphan" no longer implies "delete". ongoing effort to
separate the behavior of these two operations.
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/orm/dependency.py4
-rw-r--r--lib/sqlalchemy/orm/util.py2
-rw-r--r--test/orm/relationships.py4
4 files changed, 10 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index d1c0df454..daa2e1e57 100644
--- 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.
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py
index 86c0316f2..063d5aaa9 100644
--- a/lib/sqlalchemy/orm/dependency.py
+++ b/lib/sqlalchemy/orm/dependency.py
@@ -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)
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 6cb4fed6e..923dd6797 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -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
diff --git a/test/orm/relationships.py b/test/orm/relationships.py
index cc7eec915..6fb666dab 100644
--- a/test/orm/relationships.py
+++ b/test/orm/relationships.py
@@ -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)