diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2016-09-02 12:23:31 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ln3.zzzcomputing.com> | 2016-09-02 12:23:31 -0400 |
| commit | ce62fa2eed1d93c9b6e383e48dcfaf5380b86915 (patch) | |
| tree | d656e792fc05e9397bc8d2754c23aa7bcf58725f /lib/sqlalchemy/sql/compiler.py | |
| parent | ce577d48449588d3e5395c08c7f4d04cb8bb325f (diff) | |
| parent | 9a6947427af58eeb6ebf09ec6de2a1b7ec12d828 (diff) | |
| download | sqlalchemy-ce62fa2eed1d93c9b6e383e48dcfaf5380b86915.tar.gz | |
Merge "Allow stringify compiler to render unnamed column"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 85d5ff6da..a7954f10a 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -660,12 +660,15 @@ class SQLCompiler(Compiled): return label.element._compiler_dispatch( self, within_columns_clause=False, **kw) + def _fallback_column_name(self, column): + raise exc.CompileError("Cannot compile Column object until " + "its 'name' is assigned.") + def visit_column(self, column, add_to_result_map=None, include_table=True, **kwargs): name = orig_name = column.name if name is None: - raise exc.CompileError("Cannot compile Column object until " - "its 'name' is assigned.") + name = self._fallback_column_name(column) is_literal = column.is_literal if not is_literal and isinstance(name, elements._truncated_label): @@ -2203,6 +2206,9 @@ class StrSQLCompiler(SQLCompiler): """ + def _fallback_column_name(self, column): + return "<name unknown>" + def visit_getitem_binary(self, binary, operator, **kw): return "%s[%s]" % ( self.process(binary.left, **kw), @@ -2210,7 +2216,6 @@ class StrSQLCompiler(SQLCompiler): ) def returning_clause(self, stmt, returning_cols): - columns = [ self._label_select_column(None, c, True, False, {}) for c in elements._select_iterables(returning_cols) |
