From: Mike Bayer Date: Mon, 6 Mar 2006 01:09:03 +0000 (+0000) Subject: selects within a compound clause dont get parenthesis added X-Git-Tag: rel_0_1_4~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e59ad037b0053b66b9c3a6c84449012f3219594a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git selects within a compound clause dont get parenthesis added fix to ColumnClause --- diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index cee328b53a..5389f4bd72 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -635,6 +635,9 @@ class BindParamClause(ClauseElement, CompareMixin): Since compare() is meant to compare statement syntax, this method returns True if the two BindParamClauses have just the same type.""" return isinstance(other, BindParamClause) and other.type.__class__ == self.type.__class__ + def _make_proxy(self, selectable, name = None): + return self +# return self.obj._make_proxy(selectable, name=self.name) class TextClause(ClauseElement): """represents literal a SQL text fragment. public constructor is the @@ -988,7 +991,7 @@ class ColumnClause(ColumnElement): return BindParamClause(self.table.name + "_" + self.text, obj, shortname = self.text, type=self.type) def _make_proxy(self, selectable, name = None): c = ColumnClause(name or self.text, selectable) - selectable.columns[c.key] = c + selectable.columns[c.name] = c return c def _compare_type(self, obj): return self.type @@ -1205,6 +1208,11 @@ class Select(SelectBaseMixin, FromClause): self.is_where = is_where def visit_compound_select(self, cs): self.visit_select(cs) + # unselect the 'issubquery' flag on the selects within the compound, + # i.e. "SELECT foo UNION SELECT bar", since the enclosing compound select + # is the "subquery" + for s in cs.selects: + s.issubquery = False def visit_column(self, c):pass def visit_table(self, c):pass def visit_select(self, select):