diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-01 20:14:17 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-01 20:14:17 +0000 |
commit | 7e2ae824a56c760286e33adce03324b8e696472a (patch) | |
tree | e2b0a85db431cf4a7234aa027d2a0453aa615bfd /lib/sqlalchemy/ansisql.py | |
parent | d94384253f496be5f8db9745a2cac8fc6c82c69b (diff) | |
download | sqlalchemy-7e2ae824a56c760286e33adce03324b8e696472a.tar.gz |
- 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)
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r-- | lib/sqlalchemy/ansisql.py | 13 |
1 files changed, 9 insertions, 4 deletions
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 |