summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/functions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-10-06 11:14:29 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-10-06 11:29:09 -0400
commit4bb8397ae3a9d65bd18eb1d7c951bf5121ea280a (patch)
tree99ed437324d1ceaf1b6022216862c3eac5d15884 /lib/sqlalchemy/sql/functions.py
parent2c280791886756422a8103769cf131b0fe292ffe (diff)
downloadsqlalchemy-4bb8397ae3a9d65bd18eb1d7c951bf5121ea280a.tar.gz
Fix array_agg to accommodate ARRAY arguments
Fixed bug in :func:`.array_agg` function where passing an argument that is already of type :class:`.ARRAY`, such as a Postgresql :obj:`.postgresql.array` construct, would produce a ``ValueError``, due to the function attempting to nest the arrays. Change-Id: Ibe5f6275d90e4868e6ef8a733de05acd44c05d78 Fixes: #4107
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r--lib/sqlalchemy/sql/functions.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 9a9396fec..23bd9a568 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -689,7 +689,14 @@ class array_agg(GenericFunction):
def __init__(self, *args, **kwargs):
args = [_literal_as_binds(c) for c in args]
- kwargs.setdefault('type_', self.type(_type_from_args(args)))
+
+ 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['_parsed_args'] = args
super(array_agg, self).__init__(*args, **kwargs)