diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-15 12:25:38 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-15 12:25:38 -0400 |
commit | 3d7b18863813d98c66d76c5fbbba037d1ed18930 (patch) | |
tree | c33f34e6b72c208fa429bc03d9b811cfa61bb34a /lib/sqlalchemy/sql/compiler.py | |
parent | f4653729a6ff952555c0192a5b0f0851c4d40ad5 (diff) | |
download | sqlalchemy-3d7b18863813d98c66d76c5fbbba037d1ed18930.tar.gz |
- Fixed a SQLite join rewriting issue where a subquery that is embedded
as a scalar subquery such as within an IN would receive inappropriate
substitutions from the enclosing query, if the same table were present
inside the subquery as were in the enclosing query such as in a
joined inheritance scenario.
fixes #3130
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index da810e9fe..384cf27c2 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1297,7 +1297,6 @@ class SQLCompiler(Compiled): cloned = {} column_translate = [{}] - def visit(element, **kw): if element in column_translate[-1]: return column_translate[-1][element] @@ -1316,8 +1315,9 @@ class SQLCompiler(Compiled): right = visit(newelem.right, **kw) selectable_ = selectable.Select( - [right.element], - use_labels=True).alias() + [right.element], + use_labels=True).alias() + for c in selectable_.c: c._key_label = c.key c._label = c.name @@ -1352,14 +1352,16 @@ class SQLCompiler(Compiled): newelem.onclause = visit(newelem.onclause, **kw) - elif newelem.is_selectable and newelem._is_from_container: - # if we hit an Alias or CompoundSelect, put a marker in the - # stack. + elif newelem._is_from_container: + # if we hit an Alias, CompoundSelect or ScalarSelect, put a + # marker in the stack. kw['transform_clue'] = 'select_container' newelem._copy_internals(clone=visit, **kw) elif newelem.is_selectable and newelem._is_select: - barrier_select = kw.get('transform_clue', None) == 'select_container' - # if we're still descended from an Alias/CompoundSelect, we're + barrier_select = kw.get('transform_clue', None) == \ + 'select_container' + # if we're still descended from an + # Alias/CompoundSelect/ScalarSelect, we're # in a FROM clause, so start with a new translate collection if barrier_select: column_translate.append({}) |