summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mapping/properties.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-02-26 06:14:12 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-02-26 06:14:12 +0000
commit0e436bdbee043c651e4b389155823374aceaceed (patch)
tree605bffad46cb5c3dbb014bffe7d565b9099efcbc /lib/sqlalchemy/mapping/properties.py
parent770ec1ce7aaadffe6a98ddc581d1b05d2657a2e4 (diff)
downloadsqlalchemy-0e436bdbee043c651e4b389155823374aceaceed.tar.gz
adjustment to compile synchronizers which allows many-to-many synchronize to work even when one side of the relation has both tables in it (new unittest will be added to inheritance.py to show this...)
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r--lib/sqlalchemy/mapping/properties.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py
index c8f56746d..5aaa368f9 100644
--- a/lib/sqlalchemy/mapping/properties.py
+++ b/lib/sqlalchemy/mapping/properties.py
@@ -171,7 +171,6 @@ class PropertyLoader(MapperProperty):
else:
if self.primaryjoin is None:
self.primaryjoin = sql.join(parent.table, self.target).onclause
-
# if the foreign key wasnt specified and theres no assocaition table, try to figure
# out who is dependent on who. we dont need all the foreign keys represented in the join,
# just one of them.
@@ -572,7 +571,10 @@ class PropertyLoader(MapperProperty):
elif self.direction == PropertyLoader.MANYTOONE:
self.syncrules.append(SyncRule(self.mapper, tt, pt, dest_mapper=self.parent))
else:
- raise AssertionError("assert failed")
+ if visiting is self.primaryjoin:
+ self.syncrules.append(SyncRule(self.parent, pt, st, direction=PropertyLoader.ONETOMANY))
+ else:
+ self.syncrules.append(SyncRule(self.mapper, tt, st, direction=PropertyLoader.MANYTOONE))
elif pt and st:
self.syncrules.append(SyncRule(self.parent, pt, st, direction=PropertyLoader.ONETOMANY))
elif tt and st:
@@ -580,8 +582,10 @@ class PropertyLoader(MapperProperty):
self.syncrules = []
processor = BinaryVisitor(compile)
+ visiting = self.primaryjoin
self.primaryjoin.accept_visitor(processor)
if self.secondaryjoin is not None:
+ visiting = self.secondaryjoin
self.secondaryjoin.accept_visitor(processor)
if len(self.syncrules) == 0:
raise ArgumentError("No syncrules generated for join criterion " + str(self.primaryjoin))
@@ -622,6 +626,7 @@ class PropertyLoader(MapperProperty):
self.direction = direction
self.dest_mapper = dest_mapper
self.dest_column = dest_column
+ #print "SyncRule", source_mapper, source_column, dest_column, dest_mapper, direction
def execute(self, source, dest, obj, child, clearkeys):
if self.direction is not None: