diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/properties.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 8 |
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'): |
