mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-09 09:06:45 -04:00
OK this is the broken version, need to think a lot more about this
This commit is contained in:
@@ -1891,10 +1891,10 @@ class Query(object):
|
||||
(
|
||||
# TODO: this produces queries that fail the
|
||||
# compiler transformation in test_polymorphic_rel
|
||||
# isinstance(right_mapper._with_polymorphic_selectable, expression.Alias)
|
||||
isinstance(right_mapper._with_polymorphic_selectable, expression.Alias)
|
||||
|
||||
# current
|
||||
right_mapper.with_polymorphic
|
||||
# right_mapper.with_polymorphic
|
||||
or
|
||||
overlap # test for overlap:
|
||||
# orm/inheritance/relationships.py
|
||||
|
||||
@@ -1083,7 +1083,49 @@ class SQLCompiler(engine.Compiled):
|
||||
|
||||
# test for "unconditional" - any statement with
|
||||
# no_replacement_traverse setup, i.e. query.statement, from_self(), etc.
|
||||
traverse_options = {"cloned": {}, "unconditional": True}
|
||||
#traverse_options = {"cloned": {}, "unconditional": True}
|
||||
traverse_options = {"unconditional": True}
|
||||
|
||||
cloned = {}
|
||||
def thing(element, **kw):
|
||||
if element in cloned:
|
||||
return cloned[element]
|
||||
|
||||
newelem = cloned[element] = element._clone()
|
||||
|
||||
if newelem.__visit_name__ == 'join' and \
|
||||
isinstance(newelem.right, sql.FromGrouping):
|
||||
selectable = sql.select([newelem.right.element], use_labels=True)
|
||||
selectable = selectable.alias()
|
||||
newelem.right = selectable
|
||||
stop_on.append(selectable)
|
||||
for c in selectable.c:
|
||||
c._label = c._key_label = c.name
|
||||
adapter = sql_util.ClauseAdapter(selectable,
|
||||
traverse_options=traverse_options)
|
||||
adapter.magic_flag = True
|
||||
adapters.append(adapter)
|
||||
else:
|
||||
newelem._copy_internals(clone=thing, **kw)
|
||||
|
||||
return newelem
|
||||
|
||||
elem = thing(select)
|
||||
while adapters:
|
||||
adapt = adapters.pop(-1)
|
||||
adapt.__traverse_options__['stop_on'].extend(stop_on)
|
||||
elem = adapt.traverse(elem)
|
||||
return elem
|
||||
|
||||
|
||||
def _transform_select_for_nested_joins_orig(self, select):
|
||||
adapters = []
|
||||
stop_on = []
|
||||
|
||||
# test for "unconditional" - any statement with
|
||||
# no_replacement_traverse setup, i.e. query.statement, from_self(), etc.
|
||||
#traverse_options = {"cloned": {}, "unconditional": True}
|
||||
traverse_options = {"unconditional": True}
|
||||
|
||||
def visit_join(elem):
|
||||
if isinstance(elem.right, sql.FromGrouping):
|
||||
@@ -1109,6 +1151,7 @@ class SQLCompiler(engine.Compiled):
|
||||
adapter.__traverse_options__['stop_on'].extend(stop_on)
|
||||
adapters.append(adapter)
|
||||
|
||||
|
||||
select = visitors.cloned_traverse(select,
|
||||
traverse_options, {"join": visit_join})
|
||||
|
||||
|
||||
@@ -832,8 +832,9 @@ class ClauseAdapter(visitors.ReplacingCloningVisitor):
|
||||
newcol = self.selectable.c.get(col.name)
|
||||
return newcol
|
||||
|
||||
magic_flag = False
|
||||
def replace(self, col):
|
||||
if isinstance(col, expression.FromClause) and \
|
||||
if not self.magic_flag and isinstance(col, expression.FromClause) and \
|
||||
self.selectable.is_derived_from(col):
|
||||
return self.selectable
|
||||
elif not isinstance(col, expression.ColumnElement):
|
||||
|
||||
Reference in New Issue
Block a user