]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] Fixed bug whereby append_column()
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Jun 2012 23:02:48 +0000 (19:02 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Jun 2012 23:02:48 +0000 (19:02 -0400)
wouldn't function correctly on a cloned
select() construct, courtesy
Gunnlaugur Por Briem.  [ticket:2482]
Also in 0.7.8.

CHANGES
lib/sqlalchemy/sql/expression.py
test/sql/test_selectable.py

diff --git a/CHANGES b/CHANGES
index 0f906eee7e44f66b7a255679dae1359f95492ed6..2a30321e942a7cb5eea5bfa92116175a77abd743 100644 (file)
--- 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
index 2fe02c6904e383f7066550720701213775ad84e1..f836d7eafa26f1e967cd136977ef1fe4f517bb9b 100644 (file)
@@ -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
index 66053b794f41c4cac126c54a3c4f7cd89fc699d4..ff569288eeeb4c085fa0758e008163fecd447bcd 100644 (file)
@@ -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