summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-05-17 15:11:34 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-05-17 15:11:34 +0000
commit779068fb41a216f65f6cd18d50b261e378ed67ac (patch)
treec292d05bbe523dc0f004cafe54d5570a4694516d /lib/sqlalchemy
parentdd96699bdd754e4aa2028fab032116af48b179c6 (diff)
downloadsqlalchemy-779068fb41a216f65f6cd18d50b261e378ed67ac.tar.gz
- fix to select_by(<propname>=<object instance>) -style joins in conjunction
with many-to-many relationships, bug introduced in r2556 - the "reverse_direction" flag in _create_lazy_clause works correctly for a many-to-many relationship (i.e. the reverse is on which clause, not which column in the clause, in the case of m2m)
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/properties.py2
-rw-r--r--lib/sqlalchemy/orm/strategies.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 171021da8..6677e4ab9 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -418,6 +418,8 @@ class PropertyLoader(StrategizedProperty):
if logging.is_info_enabled(self.logger):
self.logger.info(str(self) + " setup primary join " + str(self.primaryjoin))
self.logger.info(str(self) + " setup polymorphic primary join " + str(self.polymorphic_primaryjoin))
+ self.logger.info(str(self) + " setup secondary join " + str(self.secondaryjoin))
+ self.logger.info(str(self) + " setup polymorphic secondary join " + str(self.polymorphic_secondaryjoin))
self.logger.info(str(self) + " foreign keys " + str([str(c) for c in self.foreign_keys]))
self.logger.info(str(self) + " remote columns " + str([str(c) for c in self.remote_side]))
self.logger.info(str(self) + " relation direction " + (self.direction is sync.ONETOMANY and "one-to-many" or (self.direction is sync.MANYTOONE and "many-to-one" or "many-to-many")))
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 033d0cac1..f1b159318 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -253,7 +253,7 @@ class LazyLoader(AbstractRelationLoader):
reverse = {}
def should_bind(targetcol, othercol):
- if reverse_direction:
+ if reverse_direction and not secondaryjoin:
return targetcol in remote_side
else:
return othercol in remote_side
@@ -293,10 +293,14 @@ class LazyLoader(AbstractRelationLoader):
lazywhere = primaryjoin.copy_container()
li = mapperutil.BinaryVisitor(visit_binary)
- li.traverse(lazywhere)
+
+ if not secondaryjoin or not reverse_direction:
+ li.traverse(lazywhere)
if secondaryjoin is not None:
secondaryjoin = secondaryjoin.copy_container()
+ if reverse_direction:
+ li.traverse(secondaryjoin)
lazywhere = sql.and_(lazywhere, secondaryjoin)
if hasattr(cls, 'parent_property'):