From 7e2ae824a56c760286e33adce03324b8e696472a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 1 Mar 2007 20:14:17 +0000 Subject: - use_labels flag on select() wont auto-create labels for literal text column elements, since we can make no assumptions about the text. to create labels for literal columns, you can say "somecol AS somelabel", or use literal_column("somecol").label("somelabel") - quoting wont occur for literal columns when they are "proxied" into the column collection for their selectable (is_literal flag is propigated) --- lib/sqlalchemy/ansisql.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/ansisql.py') diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index 7a167f42e..f96bf7abe 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -392,12 +392,17 @@ class ANSICompiler(sql.Compiled): continue for co in s.columns: if select.use_labels: - l = co.label(co._label) - l.accept_visitor(self) - inner_columns[co._label] = l + labelname = co._label + if labelname is not None: + l = co.label(labelname) + l.accept_visitor(self) + inner_columns[labelname] = l + else: + co.accept_visitor(self) + inner_columns[self.get_str(co)] = co # TODO: figure this out, a ColumnClause with a select as a parent # is different from any other kind of parent - elif select.is_subquery and isinstance(co, sql._ColumnClause) and co.table is not None and not isinstance(co.table, sql.Select): + elif select.is_subquery and isinstance(co, sql._ColumnClause) and not co.is_literal and co.table is not None and not isinstance(co.table, sql.Select): # SQLite doesnt like selecting from a subquery where the column # names look like table.colname, so add a label synonomous with # the column name -- cgit v1.2.1