From: Mike Bayer Date: Sat, 16 Jun 2012 23:02:48 +0000 (-0400) Subject: - [bug] Fixed bug whereby append_column() X-Git-Tag: rel_0_8_0b1~381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a48ce44f4c271bc45ed09d7253da1f1892e6272;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [bug] Fixed bug whereby append_column() wouldn't function correctly on a cloned select() construct, courtesy Gunnlaugur Por Briem. [ticket:2482] Also in 0.7.8. --- diff --git a/CHANGES b/CHANGES index 0f906eee7e..2a30321e94 100644 --- a/CHANGES +++ b/CHANGES @@ -337,6 +337,11 @@ CHANGES compound expressions, courtesy btbuilder. [ticket:2490] Also in 0.7.8. + - [bug] Fixed bug whereby append_column() + wouldn't function correctly on a cloned + select() construct, courtesy + Gunnlaugur Þór Briem. [ticket:2482] + Also in 0.7.8. - sqlite - [feature] the SQLite date and time types diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 2fe02c6904..f836d7eafa 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2190,7 +2190,7 @@ class ColumnElement(ClauseElement, _CompareMixin): co.proxies = [self] if selectable._is_clone_of is not None: co._is_clone_of = \ - selectable._is_clone_of.columns[key] + selectable._is_clone_of.columns.get(key) selectable._columns[key] = co return co @@ -4156,7 +4156,7 @@ class ColumnClause(_Immutable, ColumnElement): c.proxies = [self] if selectable._is_clone_of is not None: c._is_clone_of = \ - selectable._is_clone_of.columns[c.name] + selectable._is_clone_of.columns.get(c.name) if attach: selectable._columns[c.key] = c diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 66053b794f..ff569288ee 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -147,6 +147,13 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled assert j2.corresponding_column(table1.c.col1) \ is j2.c.table1_col1 + def test_clone_append_column(self): + sel = select([literal_column('1').label('a')]) + cloned = visitors.ReplacingCloningVisitor().traverse(sel) + cloned.append_column(literal_column('2').label('b')) + cloned.append_column(func.foo()) + eq_(cloned.c.keys(), ['a', 'b', 'foo()']) + def test_against_cloned_non_table(self): # test that corresponding column digs across # clone boundaries with anonymous labeled elements