summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/ext.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/dialects/postgresql/ext.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/dialects/postgresql/ext.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/ext.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py
index 8b08cc498..9b2e3fd73 100644
--- a/lib/sqlalchemy/dialects/postgresql/ext.py
+++ b/lib/sqlalchemy/dialects/postgresql/ext.py
@@ -7,7 +7,9 @@
from ...sql import expression
from ...sql import elements
+from ...sql import functions
from ...sql.schema import ColumnCollectionConstraint
+from .array import ARRAY
class aggregate_order_by(expression.ColumnElement):
@@ -152,3 +154,15 @@ static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
initially=self.initially)
c.dispatch._update(self.dispatch)
return c
+
+
+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`.
+
+ .. versionadded:: 1.1
+
+ """
+ kw['type_'] = ARRAY(functions._type_from_args(arg))
+ return functions.func.array_agg(*arg, **kw)