summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/functions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-08-27 11:21:25 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-08-27 11:22:05 -0400
commit410be197ef5df234205b35f0d318b106a34e7f92 (patch)
tree369b0217b874a68190833f5884b8a37f3043d159 /lib/sqlalchemy/sql/functions.py
parente2209f7534255855f33a2afedac913fbefe37484 (diff)
downloadsqlalchemy-410be197ef5df234205b35f0d318b106a34e7f92.tar.gz
- add a postgresql-specific form of array_agg() that injects the
ARRAY type, references #3132
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r--lib/sqlalchemy/sql/functions.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index d5d0eb7f2..6cfbd12b3 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -661,17 +661,24 @@ class array_agg(GenericFunction):
The ``func.array_agg(expr)`` construct returns an expression of
type :class:`.Array`.
- e.g.
+ e.g.::
stmt = select([func.array_agg(table.c.values)[2:5]])
.. versionadded:: 1.1
+ .. seealso::
+
+ :func:`.postgresql.array_agg` - PostgreSQL-specific version that
+ returns :class:`.ARRAY`, which has PG-specific operators added.
+
"""
+ type = sqltypes.Array
+
def __init__(self, *args, **kwargs):
args = [_literal_as_binds(c) for c in args]
- kwargs.setdefault('type_', sqltypes.Array(_type_from_args(args)))
+ kwargs.setdefault('type_', self.type(_type_from_args(args)))
kwargs['_parsed_args'] = args
super(array_agg, self).__init__(*args, **kwargs)