diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 5 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 22 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 4 |
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 9c79ccf7a..5c884e1a0 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -14,7 +14,6 @@ from .. import util, exc import itertools from .visitors import ClauseVisitor import re -import collections PARSE_AUTOCOMMIT = util.symbol('PARSE_AUTOCOMMIT') NO_ARG = util.symbol('NO_ARG') @@ -46,7 +45,7 @@ def _generative(fn, *args, **kw): return self -class _DialectArgView(collections.MutableMapping): +class _DialectArgView(util.collections_abc.MutableMapping): """A dictionary view of dialect-level arguments in the form <dialectname>_<argument_name>. @@ -99,7 +98,7 @@ class _DialectArgView(collections.MutableMapping): ) -class _DialectArgDict(collections.MutableMapping): +class _DialectArgDict(util.collections_abc.MutableMapping): """A dictionary view of dialect-level arguments for a specific dialect. diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index e45db428a..2f68b7e2e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -968,11 +968,7 @@ class SQLCompiler(Compiled): for i, c in enumerate(cs.selects)) ) - group_by = cs._group_by_clause._compiler_dispatch( - self, asfrom=asfrom, **kwargs) - if group_by: - text += " GROUP BY " + group_by - + text += self.group_by_clause(cs, **dict(asfrom=asfrom, **kwargs)) text += self.order_by_clause(cs, **kwargs) text += (cs._limit_clause is not None or cs._offset_clause is not None) and \ @@ -1929,10 +1925,7 @@ class SQLCompiler(Compiled): text += " \nWHERE " + t if select._group_by_clause.clauses: - group_by = select._group_by_clause._compiler_dispatch( - self, **kwargs) - if group_by: - text += " GROUP BY " + group_by + text += self.group_by_clause(select, **kwargs) if select._having is not None: t = select._having._compiler_dispatch(self, **kwargs) @@ -1988,7 +1981,18 @@ class SQLCompiler(Compiled): """ return select._distinct and "DISTINCT " or "" + def group_by_clause(self, select, **kw): + """allow dialects to customize how GROUP BY is rendered.""" + + group_by = select._group_by_clause._compiler_dispatch(self, **kw) + if group_by: + return " GROUP BY " + group_by + else: + return "" + def order_by_clause(self, select, **kw): + """allow dialects to customize how ORDER BY is rendered.""" + order_by = select._order_by_clause._compiler_dispatch(self, **kw) if order_by: return " ORDER BY " + order_by diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 08af78606..2b9ede43f 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1057,7 +1057,6 @@ class SchemaType(SchemaEventTarget): schema = kw.pop('schema', self.schema) metadata = kw.pop('metadata', self.metadata) _create_events = kw.pop('_create_events', False) - return impltype(name=self.name, schema=schema, inherit_schema=self.inherit_schema, @@ -1442,6 +1441,7 @@ class Enum(Emulated, String, SchemaType): kw.setdefault('_create_events', False) kw.setdefault('native_enum', self.native_enum) kw.setdefault('values_callable', self.values_callable) + kw.setdefault('create_constraint', self.create_constraint) assert '_enums' in kw return impltype(**kw) @@ -2098,7 +2098,7 @@ class JSON(Indexable, TypeEngine): @util.dependencies('sqlalchemy.sql.default_comparator') def _setup_getitem(self, default_comparator, index): if not isinstance(index, util.string_types) and \ - isinstance(index, collections.Sequence): + isinstance(index, compat.collections_abc.Sequence): index = default_comparator._check_literal( self.expr, operators.json_path_getitem_op, index, bindparam_type=JSON.JSONPathType |