summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/ext.py5
-rw-r--r--lib/sqlalchemy/sql/functions.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py
index 20ed0fc8d..71fb3cc5b 100644
--- a/lib/sqlalchemy/dialects/postgresql/ext.py
+++ b/lib/sqlalchemy/dialects/postgresql/ext.py
@@ -209,10 +209,11 @@ static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
def array_agg(*arg, **kw):
"""PostgreSQL-specific form of :class:`.array_agg`, ensures
return type is :class:`.postgresql.ARRAY` and not
- the plain :class:`.types.ARRAY`.
+ the plain :class:`.types.ARRAY`, unless an explicit ``type_``
+ is passed.
.. versionadded:: 1.1
"""
- kw['type_'] = ARRAY(functions._type_from_args(arg))
+ kw['_default_array_type'] = ARRAY
return functions.func.array_agg(*arg, **kw)
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 27d030d4f..5cea7750a 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -793,13 +793,14 @@ class array_agg(GenericFunction):
def __init__(self, *args, **kwargs):
args = [_literal_as_binds(c) for c in args]
+ default_array_type = kwargs.pop('_default_array_type', sqltypes.ARRAY)
if 'type_' not in kwargs:
type_from_args = _type_from_args(args)
if isinstance(type_from_args, sqltypes.ARRAY):
kwargs['type_'] = type_from_args
else:
- kwargs['type_'] = sqltypes.ARRAY(type_from_args)
+ kwargs['type_'] = default_array_type(type_from_args)
kwargs['_parsed_args'] = args
super(array_agg, self).__init__(*args, **kwargs)