diff options
author | Jonathan Ellis <jbellis@gmail.com> | 2006-07-21 16:53:05 +0000 |
---|---|---|
committer | Jonathan Ellis <jbellis@gmail.com> | 2006-07-21 16:53:05 +0000 |
commit | 52c50cb72be72c6caed7bc0c5a29e9f18831c3d3 (patch) | |
tree | bf6d76e3eb1a915c94b72cc28e7bfbcb9a843371 /lib/sqlalchemy/ansisql.py | |
parent | 6fed7d0166e96acbeb2b7fa6e46c4747e9529d57 (diff) | |
download | sqlalchemy-52c50cb72be72c6caed7bc0c5a29e9f18831c3d3.tar.gz |
_selectable interface; allows sqlsoup to pass its classes to Join and have the underlying Table pulled out
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r-- | lib/sqlalchemy/ansisql.py | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index 3ba296576..7a76eddbe 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -309,27 +309,30 @@ class ANSICompiler(sql.Compiled): if isinstance(c, sql.Select) and c._scalar: c.accept_visitor(self) inner_columns[self.get_str(c)] = c - elif c.is_selectable(): - for co in c.columns: - if select.use_labels: - l = co.label(co._label) - l.accept_visitor(self) - inner_columns[co._label] = l - # TODO: figure this out, a ColumnClause with a select as a parent - # is different from any other kind of parent - elif select.issubquery and isinstance(co, sql.ColumnClause) 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 - l = co.label(co.name) - l.accept_visitor(self) - inner_columns[self.get_str(l.obj)] = l - else: - co.accept_visitor(self) - inner_columns[self.get_str(co)] = co - else: + continue + try: + s = c._selectable() + except AttributeError: c.accept_visitor(self) inner_columns[self.get_str(c)] = c + continue + for co in s.columns: + if select.use_labels: + l = co.label(co._label) + l.accept_visitor(self) + inner_columns[co._label] = l + # TODO: figure this out, a ColumnClause with a select as a parent + # is different from any other kind of parent + elif select.issubquery and isinstance(co, sql.ColumnClause) 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 + l = co.label(co.name) + l.accept_visitor(self) + inner_columns[self.get_str(l.obj)] = l + else: + co.accept_visitor(self) + inner_columns[self.get_str(co)] = co self.select_stack.pop(-1) collist = string.join([self.get_str(v) for v in inner_columns.values()], ', ') |