summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-11-07 17:08:23 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-11-07 17:08:23 +0000
commit17b758faed4dfdc7973d0c0b861ece40de10b101 (patch)
tree371bffbf27b725a9c1ade23c33546869e7b381f7 /lib/sqlalchemy/sql
parentabf9bef1a9f548a373f05b8a328d815dd28dda30 (diff)
downloadsqlalchemy-17b758faed4dfdc7973d0c0b861ece40de10b101.tar.gz
avoid some often unnecessary method calls. i think we might have squeezed all we're going to squeeze out of compiler at this point.
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/compiler.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 1c7c66f47..851bc30ac 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -459,7 +459,8 @@ class DefaultCompiler(engine.Compiled):
column.table is not None and \
not isinstance(column.table, sql.Select):
return _CompileLabel(column, sql._generated_label(column.name))
- elif not isinstance(column, (sql._UnaryExpression, sql._TextClause, sql._BindParamClause)) and (not hasattr(column, 'name') or isinstance(column, sql._Function)):
+ elif not isinstance(column, (sql._UnaryExpression, sql._TextClause, sql._BindParamClause)) \
+ and (not hasattr(column, 'name') or isinstance(column, sql._Function)):
return _CompileLabel(column, column.anon_label)
else:
return column
@@ -479,13 +480,13 @@ class DefaultCompiler(engine.Compiled):
# if existingfroms:
# correlate_froms = correlate_froms.union(existingfroms)
+ self.stack.append({'from':correlate_froms, 'iswrapper':iswrapper})
+
if compound_index==1 and not entry or entry.get('iswrapper', False):
column_clause_args = {'result_map':self.result_map}
else:
column_clause_args = {}
- self.stack.append({'from':correlate_froms, 'iswrapper':iswrapper})
-
# the actual list of columns to print in the SELECT column list.
inner_columns = util.unique_list(
c for c in [
@@ -515,18 +516,22 @@ class DefaultCompiler(engine.Compiled):
if t:
text += " \nWHERE " + t
- group_by = self.process(select._group_by_clause)
- if group_by:
- text += " GROUP BY " + group_by
+ if select._group_by_clause.clauses:
+ group_by = self.process(select._group_by_clause)
+ if group_by:
+ text += " GROUP BY " + group_by
if select._having is not None:
t = self.process(select._having)
if t:
text += " \nHAVING " + t
- text += self.order_by_clause(select)
- text += (select._limit is not None or select._offset is not None) and self.limit_clause(select) or ""
- text += self.for_update_clause(select)
+ if select._order_by_clause.clauses:
+ text += self.order_by_clause(select)
+ if select._limit is not None or select._offset is not None:
+ text += self.limit_clause(select)
+ if select.for_update:
+ text += self.for_update_clause(select)
self.stack.pop(-1)