diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-16 19:02:48 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-16 19:02:48 -0400 |
| commit | 6a48ce44f4c271bc45ed09d7253da1f1892e6272 (patch) | |
| tree | 5f7d88cf02799a79a6656af27c118f1f6c9da167 | |
| parent | 3ebb7d8e942ded31efbdb052ae3a1f08a6fc3d3d (diff) | |
| download | sqlalchemy-6a48ce44f4c271bc45ed09d7253da1f1892e6272.tar.gz | |
- [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.
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 4 | ||||
| -rw-r--r-- | test/sql/test_selectable.py | 7 |
3 files changed, 14 insertions, 2 deletions
@@ -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 2fe02c690..f836d7eaf 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 66053b794..ff569288e 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 |
