summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mapping/properties.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-02-01 23:21:36 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-02-01 23:21:36 +0000
commitd3bc393c43d19e719c155ee65e2f2ce83094514e (patch)
treed3c76d0058b1337b5c378eb4d290e12e21be6b75 /lib/sqlalchemy/mapping/properties.py
parent42cea08d8877bbc9362ff9547a2c3e408f2ed707 (diff)
downloadsqlalchemy-d3bc393c43d19e719c155ee65e2f2ce83094514e.tar.gz
merged new cyclical dependency code
EagerRelation gets a fix w/ regards to selectalias
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r--lib/sqlalchemy/mapping/properties.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py
index dc64cae97..5f15a8d2c 100644
--- a/lib/sqlalchemy/mapping/properties.py
+++ b/lib/sqlalchemy/mapping/properties.py
@@ -347,16 +347,18 @@ class PropertyLoader(MapperProperty):
uow.register_deleted(child)
class MapperStub(object):
- """poses as a Mapper representing the association table in a many-to-many
- join, when performing a commit().
-
- The Task objects in the objectstore module treat it just like
- any other Mapper, but in fact it only serves as a "dependency" placeholder
- for the many-to-many update task."""
- def save_obj(self, *args, **kwargs):
- pass
- def delete_obj(self, *args, **kwargs):
- pass
+ """poses as a Mapper representing the association table in a many-to-many
+ join, when performing a commit().
+
+ The Task objects in the objectstore module treat it just like
+ any other Mapper, but in fact it only serves as a "dependency" placeholder
+ for the many-to-many update task."""
+ def __init__(self, mapper):
+ self.mapper = mapper
+ def save_obj(self, *args, **kwargs):
+ pass
+ def delete_obj(self, *args, **kwargs):
+ pass
def register_dependencies(self, uowcommit):
"""tells a UOWTransaction what mappers are dependent on which, with regards
@@ -373,7 +375,7 @@ class PropertyLoader(MapperProperty):
# association/parent->stub->self, then we process the child
# elments after the 'stub' save, which is before our own
# mapper's save.
- stub = PropertyLoader.MapperStub()
+ stub = PropertyLoader.MapperStub(self.association)
uowcommit.register_dependency(self.parent, stub)
uowcommit.register_dependency(self.association, stub)
uowcommit.register_dependency(stub, self.mapper)
@@ -391,7 +393,7 @@ class PropertyLoader(MapperProperty):
# if we are the "backref" half of a two-way backref
# relationship, let the other mapper handle inserting the rows
return
- stub = PropertyLoader.MapperStub()
+ stub = PropertyLoader.MapperStub(self.mapper)
uowcommit.register_dependency(self.parent, stub)
uowcommit.register_dependency(self.mapper, stub)
uowcommit.register_processor(stub, self, self.parent, False)
@@ -410,13 +412,16 @@ class PropertyLoader(MapperProperty):
return uowcommit.uow.attributes.get_history(obj, self.key, passive = passive)
def whose_dependent_on_who(self, obj1, obj2):
+ """given an object pair assuming obj2 is a child of obj1, returns a tuple
+ with the dependent object second, or None if they are equal.
+ used by objectstore's object-level topoligical sort."""
if obj1 is obj2:
return None
elif self.direction == PropertyLoader.ONETOMANY:
return (obj1, obj2)
else:
return (obj2, obj1)
-
+
def process_dependencies(self, task, deplist, uowcommit, delete = False):
#print self.mapper.table.name + " " + self.key + " " + repr(len(deplist)) + " process_dep isdelete " + repr(delete) + " direction " + repr(self.direction)
@@ -518,15 +523,16 @@ class PropertyLoader(MapperProperty):
for child in childlist.added_items():
self._synchronize(obj, child, None, False)
if self.direction == PropertyLoader.ONETOMANY:
+ # for a cyclical task, this registration is handled by the objectstore
uowcommit.register_object(child)
if self.direction != PropertyLoader.MANYTOONE or len(childlist.added_items()) == 0:
for child in childlist.deleted_items():
if not self.private:
self._synchronize(obj, child, None, True)
if self.direction == PropertyLoader.ONETOMANY:
+ # for a cyclical task, this registration is handled by the objectstore
uowcommit.register_object(child, isdelete=self.private)
-
def _synchronize(self, obj, child, associationrow, clearkeys):
if self.direction == PropertyLoader.ONETOMANY:
source = obj
@@ -682,7 +688,8 @@ class EagerLoader(PropertyLoader):
if self.secondaryjoin is not None:
self.eagersecondary = self.secondaryjoin.copy_container()
self.eagersecondary.accept_visitor(aliasizer)
- self.eagerpriamry = self.primaryjoin
+ self.eagerprimary = self.primaryjoin.copy_container()
+ self.eagerprimary.accept_visitor(aliasizer)
else:
self.eagerprimary = self.primaryjoin.copy_container()
self.eagerprimary.accept_visitor(aliasizer)
@@ -722,7 +729,7 @@ class EagerLoader(PropertyLoader):
towrap = self.parent.table
if self.secondaryjoin is not None:
- statement._outerjoin = sql.outerjoin(towrap, self.secondary, self.primaryjoin).outerjoin(self.eagertarget, self.eagersecondary)
+ statement._outerjoin = sql.outerjoin(towrap, self.secondary, self.eagerprimary).outerjoin(self.eagertarget, self.eagersecondary)
if self.order_by is False and self.secondary.default_order_by() is not None:
statement.order_by(*self.secondary.default_order_by())
else: