Mike Bayer avatar Mike Bayer committed dfa8b6e

- [bug] Fixed bug whereby append_column()
wouldn't function correctly on a cloned
select() construct, courtesy
Gunnlaugur Por Briem. [ticket:2482]

Comments (0)

Files changed (3)

     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

lib/sqlalchemy/sql/expression.py

         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
 
         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

test/sql/test_selectable.py

         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.