summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-10-31 00:51:16 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-10-31 00:51:16 +0000
commit9bb80a8f11d73c8c30c5c44ef33b05ec2c8d2d20 (patch)
tree5757702aaf95a7203a93edbad197d2dee65c6ba8
parentb2c68fab83092eb760e07c63c64274bf59f46f54 (diff)
downloadsqlalchemy-9bb80a8f11d73c8c30c5c44ef33b05ec2c8d2d20.tar.gz
figured out how a Select can be in its own _froms list, changed assertion to just a continue
-rw-r--r--lib/sqlalchemy/sql.py6
-rw-r--r--test/sql/select.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 61b3d277a..ce33810a5 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -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
diff --git a/test/sql/select.py b/test/sql/select.py
index 2804da344..1c8927e6b 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -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"),