--- /dev/null
+.. change::
+ :tags: bug, sql
+ :tickets: 4780
+
+ Fixed issue where internal cloning of SELECT constructs could lead to a key
+ error if the copy of the SELECT changed its state such that its list of
+ columns changed. This was observed to be occurring in some ORM scenarios
+ which may be unique to 1.3 and above, so is partially a regression fix.
+
+
c.table = selectable
selectable._columns.add(c)
if selectable._is_clone_of is not None:
- c._is_clone_of = selectable._is_clone_of.columns[c.key]
+ c._is_clone_of = selectable._is_clone_of.columns.get(c.key)
if self.primary_key:
selectable.primary_key.add(c)
c.dispatch.after_parent_attach(c, selectable)
cloned.append_column(func.foo())
eq_(list(cloned.c.keys()), ["a", "b", "foo()"])
+ def test_clone_col_list_changes_then_proxy(self):
+ t = table("t", column("q"), column("p"))
+ stmt = select([t.c.q]).alias()
+
+ def add_column(stmt):
+ stmt.append_column(t.c.p)
+
+ stmt2 = visitors.cloned_traverse(stmt, {}, {"select": add_column})
+ eq_(list(stmt.c.keys()), ["q"])
+ eq_(list(stmt2.c.keys()), ["q", "p"])
+
+ def test_clone_col_list_changes_then_schema_proxy(self):
+ t = Table("t", MetaData(), Column("q", Integer), Column("p", Integer))
+ stmt = select([t.c.q]).alias()
+
+ def add_column(stmt):
+ stmt.append_column(t.c.p)
+
+ stmt2 = visitors.cloned_traverse(stmt, {}, {"select": add_column})
+ eq_(list(stmt.c.keys()), ["q"])
+ eq_(list(stmt2.c.keys()), ["q", "p"])
+
def test_append_column_after_replace_selectable(self):
basesel = select([literal_column("1").label("a")])
tojoin = select(