summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-01-24 23:37:03 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-01-24 23:37:03 +0000
commit9349ef38efad07157c163afa387820c870ce97e9 (patch)
treec454b9d418573641524127326d8592d849521cd8 /lib
parent142d3f4bfd1296c045eda3e711c424a52825dab0 (diff)
downloadsqlalchemy-9349ef38efad07157c163afa387820c870ce97e9.tar.gz
- calling corresponding_column with keys_ok matches columns on name, not key, since
the name is meaningful with regards to SQL relationships, the key is not - adjustments to the recent polymorphic relationship refactorings, specifically for many-to-one relationships to polymorphic unions that did not contain the base table [ticket:439]. the lazy/eager clause adaption to the selectable will match up on straight column names (i.e. its a more liberal policy) - lazy loader will not attempt to adapt the clause to the selectable if loads_polymorphic is not enabled, since the more liberal policy of adapting columns fails for more elaborate join conditions - will have to see if ppl want to do complex joins with polymorphic relations... may have to add "polymorphic_primaryjoin" in that case as a last resort (would make working around these issues a snap, tho...)
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/strategies.py9
-rw-r--r--lib/sqlalchemy/sql.py4
-rw-r--r--lib/sqlalchemy/sql_util.py4
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 2a33c4ff0..af52cd4e9 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -299,11 +299,14 @@ class LazyLoader(AbstractRelationLoader):
if secondaryjoin is not None:
secondaryjoin = secondaryjoin.copy_container()
- secondaryjoin.accept_visitor(sql_util.ClauseAdapter(select_table))
+ if self.loads_polymorphic:
+ secondaryjoin.accept_visitor(sql_util.ClauseAdapter(select_table))
lazywhere = sql.and_(lazywhere, secondaryjoin)
else:
- lazywhere.accept_visitor(sql_util.ClauseAdapter(select_table))
-
+ if self.loads_polymorphic:
+ lazywhere.accept_visitor(sql_util.ClauseAdapter(select_table))
+
+ print "LAZY CLAUSE", self.key, str(select_table), str(lazywhere)
LazyLoader.logger.info("create_lazy_clause " + str(lazywhere))
return (lazywhere, binds, reverse)
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 5b960546e..559847261 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -732,7 +732,7 @@ class FromClause(Selectable):
"""given a ColumnElement, return the ColumnElement object from this
Selectable which corresponds to that original Column via a proxy relationship."""
if require_exact:
- if self.columns.get(column.key) is column:
+ if self.columns.get(column.name) is column:
return column
else:
if not raiseerr:
@@ -747,7 +747,7 @@ class FromClause(Selectable):
else:
if keys_ok:
try:
- return self.c[column.key]
+ return self.c[column.name]
except KeyError:
pass
if not raiseerr:
diff --git a/lib/sqlalchemy/sql_util.py b/lib/sqlalchemy/sql_util.py
index 4c6cd4d07..6b87a2dec 100644
--- a/lib/sqlalchemy/sql_util.py
+++ b/lib/sqlalchemy/sql_util.py
@@ -139,11 +139,11 @@ class ClauseAdapter(sql.ClauseVisitor):
self.selectable = selectable
def visit_binary(self, binary):
if isinstance(binary.left, sql.ColumnElement):
- col = self.selectable.corresponding_column(binary.left, raiseerr=False, keys_ok=False)
+ col = self.selectable.corresponding_column(binary.left, raiseerr=False, keys_ok=True)
if col is not None:
binary.left = col
if isinstance(binary.right, sql.ColumnElement):
- col = self.selectable.corresponding_column(binary.right, raiseerr=False, keys_ok=False)
+ col = self.selectable.corresponding_column(binary.right, raiseerr=False, keys_ok=True)
if col is not None:
binary.right = col