]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- merge of trunk r6611
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 3 Jan 2010 20:58:04 +0000 (20:58 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 3 Jan 2010 20:58:04 +0000 (20:58 +0000)
- Fixed a column arithmetic bug that affected column
correspondence for cloned selectables which contain
free-standing column expressions.   This bug is
generally only noticeable when exercising newer
ORM behavior only availble in 0.6 via [ticket:1568],
but is more correct at the SQL expression level
as well. [ticket:1617]

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

diff --git a/CHANGES b/CHANGES
index 305ca2b9882b3268f2bd498a268c8d92c1aebba8..b25239af851d4fdf35bdb3e7c8ef631283e4f360 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,7 +11,15 @@ CHANGES
       unnamed Column objects. This allows easy creation of 
       declarative helpers which place common columns on multiple 
       subclasses.
-      
+    
+    - Fixed a column arithmetic bug that affected column
+      correspondence for cloned selectables which contain
+      free-standing column expressions.   This bug is
+      generally only noticeable when exercising newer 
+      ORM behavior only availble in 0.6 via [ticket:1568], 
+      but is more correct at the SQL expression level 
+      as well. [ticket:1617]
+    
 - postgresql
     - The extract() function, which was slightly improved in
       0.5.7, needed a lot more work to generate the correct
index 2341cf79c2154ef205582a95d0e630f8841c11e8..c9ef37c8b7f8cdd48897f567bb0204dac33c0fb4 100644 (file)
@@ -1843,7 +1843,8 @@ class FromClause(Selectable):
         target_set = column.proxy_set
         cols = self.c
         for c in cols:
-            i = c.proxy_set.intersection(target_set)
+            i = target_set.intersection(itertools.chain(*[p._cloned_set for p in c.proxy_set]))
+
             if i and \
                 (not require_embedded or c.proxy_set.issuperset(target_set)):
                 
index b0501c913498fde138566bb4fdc9de2a3c0f66a9..d1fd0114118dda01607eafb641df2312fd8b4b5c 100644 (file)
@@ -57,7 +57,20 @@ class SelectableTest(TestBase, AssertsExecutionResults):
         # test alias of the join
         j2 = jjj.alias('foo')
         assert j2.corresponding_column(table1.c.col1) is j2.c.table1_col1
+    
+    def test_against_cloned_non_table(self):
+        # test that corresponding column digs across
+        # clone boundaries with anonymous labeled elements
+        col = func.count().label('foo')
+        sel = select([col])
+        
+        sel2 = visitors.ReplacingCloningVisitor().traverse(sel)
+        assert sel2.corresponding_column(col) is sel2.c.foo
 
+        sel3 = visitors.ReplacingCloningVisitor().traverse(sel2)
+        assert sel3.corresponding_column(col) is sel3.c.foo
+
+        
     def test_select_on_table(self):
         sel = select([table1, table2], use_labels=True)
         assert sel.corresponding_column(table1.c.col1) is sel.c.table1_col1