]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Streamlined the process by which a Select
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 May 2011 17:28:38 +0000 (13:28 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 May 2011 17:28:38 +0000 (13:28 -0400)
determines what's in it's '.c' collection.
Behaves identically, except that a
raw ClauseList() passed to select([])
(which is not a documented case anyway) will
now be expanded into its individual column
elements instead of being ignored.

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

diff --git a/CHANGES b/CHANGES
index 7863daa8c8f7330f8f42c53d56ab219d778c831e..a946f2cac6a5885243588fc77ed05ed362713b79 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,18 @@
 =======
 CHANGES
 =======
+0.7.1
+=====
+
+- sql
+  - Streamlined the process by which a Select
+    determines what's in it's '.c' collection.
+    Behaves identically, except that a 
+    raw ClauseList() passed to select([]) 
+    (which is not a documented case anyway) will
+    now be expanded into its individual column
+    elements instead of being ignored.
+
 0.7.0
 =======
 - This section documents those changes from 0.7b4
index eb40e9d40dafa047ef7ec2ac609b71b7a9f5685d..0d98c89e5a996df9004db199da107f3d4b1d8c37 100644 (file)
@@ -5058,19 +5058,11 @@ class Select(_SelectBase):
 
         self._froms = self._froms.union([fromclause])
 
-    def __exportable_columns(self):
-        for column in self._raw_columns:
-            if isinstance(column, Selectable):
-                for co in column.columns:
-                    yield co
-            elif isinstance(column, ColumnElement):
-                yield column
-            else:
-                continue
 
     def _populate_column_collection(self):
-        for c in self.__exportable_columns():
-            c._make_proxy(self, name=self.use_labels and c._label or None)
+        for c in self.inner_columns:
+            if hasattr(c, '_make_proxy'):
+                c._make_proxy(self, name=self.use_labels and c._label or None)
 
     def self_group(self, against=None):
         """return a 'grouping' construct as per the ClauseElement
index 47d81b8793224ce9a291316d2ade77a5de864e56..af11694dc3415d417ca3e85811d4813506230a30 100644 (file)
@@ -319,6 +319,34 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
             "SELECT c FROM (SELECT (SELECT (SELECT table1.col1 AS a FROM table1) AS b) AS c)"
         )
 
+    def test_unusual_column_elements_text(self):
+        """test that .c excludes text()."""
+
+        s = select([table1.c.col1, text("foo")])
+        eq_(
+            list(s.c),
+            [s.c.col1]
+        )
+
+    def test_unusual_column_elements_clauselist(self):
+        """Test that raw ClauseList is expanded into .c."""
+
+        from sqlalchemy.sql.expression import ClauseList
+        s = select([table1.c.col1, ClauseList(table1.c.col2, table1.c.col3)])
+        eq_(
+            list(s.c),
+            [s.c.col1, s.c.col2, s.c.col3]
+        )
+
+    def test_unusual_column_elements_boolean_clauselist(self):
+        """test that BooleanClauseList is placed as single element in .c."""
+
+        c2 = and_(table1.c.col2==5, table1.c.col3==4)
+        s = select([table1.c.col1, c2])
+        eq_(
+            list(s.c),
+            [s.c.col1, s.corresponding_column(c2)]
+        )
 
 class AnonLabelTest(fixtures.TestBase):
     """Test behaviors that we hope to change with [ticket:2168]."""