summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mapper.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-10-15 03:11:48 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-10-15 03:11:48 +0000
commit8e9789d0afde22be08657d25ccaf787ddfebd570 (patch)
tree99dad1b5e23f099e285d1e53378849140d79e7f0 /lib/sqlalchemy/mapper.py
parent7ac7b35807f9720b2912d3180535e2a364375e2d (diff)
downloadsqlalchemy-8e9789d0afde22be08657d25ccaf787ddfebd570.tar.gz
Diffstat (limited to 'lib/sqlalchemy/mapper.py')
-rw-r--r--lib/sqlalchemy/mapper.py49
1 files changed, 29 insertions, 20 deletions
diff --git a/lib/sqlalchemy/mapper.py b/lib/sqlalchemy/mapper.py
index 04f73f85c..d6c22e22d 100644
--- a/lib/sqlalchemy/mapper.py
+++ b/lib/sqlalchemy/mapper.py
@@ -724,6 +724,7 @@ class PropertyLoader(MapperProperty):
uowcommit.register_dependency(self.parent, self.mapper)
uowcommit.register_processor(self.parent, False, self, self.parent, False)
uowcommit.register_processor(self.parent, True, self, self.parent, True)
+ #uowcommit.register_processor(self.mapper, False, self, self.parent, True)
elif self.direction == PropertyLoader.RIGHT:
uowcommit.register_dependency(self.mapper, self.parent)
uowcommit.register_processor(self.mapper, False, self, self.parent, False)
@@ -802,32 +803,40 @@ class PropertyLoader(MapperProperty):
if len(secondary_insert):
statement = self.secondary.insert()
statement.execute(*secondary_insert)
- # TODO: shouldnt this be for all deletes? propertyloader.RIGHT + delete should
- # be explicitly named
+ elif self.direction == PropertyLoader.RIGHT and delete:
+ # head object is being deleted, and we manage a foreign key object.
+ # dont have to do anything to it.
+ pass
elif self.direction == PropertyLoader.LEFT and delete:
- if not self.private:
- updates = []
- clearkeys = True
- for obj in deplist:
+ # 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
+ if self.private:
+ # if we are privately managed, then all our objects should
+ # have been marked as "todelete" already and no attribute adjustment is needed
+ return
+ updates = []
+ clearkeys = True
+ for obj in deplist:
+ if not self.private:
params = {}
for bind in self.lazybinds.values():
params[bind.key] = self.parent._getattrbycolumn(obj, self.parent.table.c[bind.shortname])
updates.append(params)
- childlist = getlist(obj, False)
- for child in childlist.deleted_items() + childlist.unchanged_items():
- # TODO: if self.private, mark child objects to be deleted ?
- self.primaryjoin.accept_visitor(setter)
- uowcommit.register_deleted_list(childlist)
- if len(updates):
- values = {}
- for bind in self.lazybinds.values():
- values[bind.shortname] = None
- statement = self.target.update(self.lazywhere, values = values)
- statement.execute(*updates)
+ childlist = getlist(obj, False)
+ for child in childlist.deleted_items() + childlist.unchanged_items():
+ self.primaryjoin.accept_visitor(setter)
+ uowcommit.register_object(child)
+ uowcommit.register_deleted_list(childlist)
+ if len(updates):
+ values = {}
+ for bind in self.lazybinds.values():
+ values[bind.shortname] = None
+ statement = self.target.update(self.lazywhere, values = values)
+ statement.execute(*updates)
else:
for obj in deplist:
if self.direction == PropertyLoader.RIGHT:
- task.append(obj)
+ uowcommit.register_object(obj)
childlist = getlist(obj)
if childlist is None: return
uowcommit.register_saved_list(childlist)
@@ -835,13 +844,13 @@ class PropertyLoader(MapperProperty):
for child in childlist.added_items():
self.primaryjoin.accept_visitor(setter)
if self.direction == PropertyLoader.LEFT:
- task.append(child)
+ uowcommit.register_object(child)
if self.direction != PropertyLoader.RIGHT or len(childlist.added_items()) == 0:
clearkeys = True
for child in childlist.deleted_items():
self.primaryjoin.accept_visitor(setter)
if self.direction == PropertyLoader.LEFT:
- task.append(child)
+ uowcommit.register_object(child)
def _sync_foreign_keys(self, binary, obj, child, associationrow, clearkeys):
"""given a binary clause with an = operator joining two table columns, synchronizes the values