]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
figured out how a Select can be in its own _froms list, changed assertion to just...
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Oct 2006 00:51:16 +0000 (00:51 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Oct 2006 00:51:16 +0000 (00:51 +0000)
lib/sqlalchemy/sql.py
test/sql/select.py

index 61b3d277aa852b4d06626b473ea5270d475e32ff..ce33810a523eb007d03607c27262e8e65710be10 100644 (file)
@@ -1455,6 +1455,7 @@ class Select(_SelectBaseMixin, FromClause):
         self._correlator = Select._CorrelatedVisitor(self, False)
         self._wherecorrelator = Select._CorrelatedVisitor(self, True)
 
+
         self.group_by(*(group_by or [None]))
         self.order_by(*(order_by or [None]))
         
@@ -1543,8 +1544,9 @@ class Select(_SelectBaseMixin, FromClause):
     def _locate_oid_column(self):
         for f in self._froms.values():
             if f is self:
-                # TODO: why would we be in our own _froms list ?
-                raise exceptions.AssertionError("Select statement should not be in its own _froms list")
+                # we might be in our own _froms list if a column with us as the parent is attached,
+                # which includes textual columns. 
+                continue
             oid = f.oid_column
             if oid is not None:
                 return oid
index 2804da3445e63f040532eefbb2329c5c840e59cb..1c8927e6b19b3e15bd2e6145fc2aed9ef9b69e3b 100644 (file)
@@ -314,6 +314,11 @@ WHERE mytable.myid = myothertable.otherid) AS t2view WHERE t2view.mytable_myid =
         s.append_from("table1")
         self.runtest(s, "SELECT column1, column2 FROM table1 WHERE column1=12 AND column2=19 ORDER BY column1")
 
+    def testtextcolumns(self):
+        self.runtest(
+            select(["column1", "column2"], from_obj=[table1]).alias('somealias').select(),
+            "SELECT somealias.column1, somealias.column2 FROM (SELECT column1, column2 FROM mytable) AS somealias"
+        )
     def testtextbinds(self):
         self.runtest(
             text("select * from foo where lala=:bar and hoho=:whee"),