- _Label class overrides compare_self to return its ultimate object.
meaning, if you say someexpr.label('foo') == 5, it produces
the correct "someexpr == 5".
+ - _Label propigates "_hide_froms()" so that scalar selects
+ behave more properly with regards to FROM clause #574
- fix to long name generation when using oid_column as an order by
(oids used heavily in mapper queries)
- orm
def _get_from_objects(self):
return self.obj._get_from_objects()
+ def _hide_froms(self):
+ return self.obj._hide_froms()
+
def _make_proxy(self, selectable, name = None):
if isinstance(self.obj, Selectable):
return self.obj._make_proxy(selectable, name=self.name)
if self.is_scalar and not hasattr(self, 'type'):
self.type = column.type
-
+
# if the column is a Select statement itself,
# accept visitor
self.__correlator.traverse(column)
def testdontovercorrelate(self):
self.runtest(select([table1], from_obj=[table1, table1.select()]), """SELECT mytable.myid, mytable.name, mytable.description FROM mytable, (SELECT mytable.myid AS myid, mytable.name AS name, mytable.description AS description FROM mytable)""")
- def testselectexists(self):
+ def testexistsascolumnclause(self):
self.runtest(exists([table1.c.myid], table1.c.myid==5).select(), "SELECT EXISTS (SELECT mytable.myid AS myid FROM mytable WHERE mytable.myid = :mytable_myid)", params={'mytable_myid':5})
+
+ self.runtest(select([table1, exists([1], from_obj=[table2])]), "SELECT mytable.myid, mytable.name, mytable.description, EXISTS (SELECT 1 FROM myothertable) FROM mytable", params={})
+
+ self.runtest(select([table1, exists([1], from_obj=[table2]).label('foo')]), "SELECT mytable.myid, mytable.name, mytable.description, (EXISTS (SELECT 1 FROM myothertable)) AS foo FROM mytable", params={})
def testwheresubquery(self):
# TODO: this tests that you dont get a "SELECT column" without a FROM but its not working yet.