]> 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:05:37 +0000 (19:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Jun 2012 23:05:37 +0000 (19:05 -0400)
wouldn't function correctly on a cloned
select() construct, courtesy
Gunnlaugur Por Briem.  [ticket:2482]

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

diff --git a/CHANGES b/CHANGES
index 63d8c1162d2a8d027da18a415c3f6920623829c7..16bbdd7022975162723cf9ceddf4fa5e06147e53 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -49,6 +49,11 @@ CHANGES
     compound expressions, courtesy btbuilder.  
     [ticket:2490]
 
+  - [bug] Fixed bug whereby append_column()
+    wouldn't function correctly on a cloned
+    select() construct, courtesy 
+    Gunnlaugur Þór Briem.  [ticket:2482]
+
 - engine
   - [bug] Fixed memory leak in C version of
     result proxy whereby DBAPIs which don't deliver
index fbead90b3f585c9ed86eb110b34f0dc903a24517..b308a7b05a0108c0d92457fc22c34a4de587be1f 100644 (file)
@@ -2172,7 +2172,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
 
@@ -4138,7 +4138,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.name] = c
index bbb9131a5225710c7967638928685bbfeafca972..d5cf724e676ea62e2bf34cd78565c17b3a3dd977 100644 (file)
@@ -138,6 +138,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