[Sqlalchemy-tickets] Issue #4324: array_agg ignores keyword type_ hint for postgres dialect, failin
Brought to you by:
zzzeek
From: Dmitry N. <iss...@bi...> - 2018-08-22 09:22:53
|
New issue 4324: array_agg ignores keyword type_ hint for postgres dialect, failing for a nested array https://bitbucket.org/zzzeek/sqlalchemy/issues/4324/array_agg-ignores-keyword-type_-hint-for Dmitry Nikonov: Hello. This issue is quite similar to the #4107 but about the [postgresql dialect version](https://bitbucket.org/zzzeek/sqlalchemy/src/master/lib/sqlalchemy/dialects/postgresql/ext.py#lines-209) of the `array_agg`. I suppose it should be fixed in the same manner. Code to reproduce (Python 3.7.0, SQLAlchemy 1.2.11): ```python from sqlalchemy import * from sqlalchemy.dialects import postgresql col = column('foo', postgresql.ARRAY(Integer)) function = func.array_agg(col, type_=ARRAY(Integer)) # Works fine function = func.array_agg(col, type_=postgresql.ARRAY(Integer)) # Works fine too function = postgresql.array_agg(col, type_=ARRAY(Integer)) # Fails with the trace shown below function = postgresql.array_agg(col, type_=postgresql.ARRAY(Integer)) # Fails with the same trace ``` Stack trace: ``` --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-8-841c5b8114ad> in <module>() ----> 1 function = postgresql.array_agg(col, type_=postgresql.ARRAY(Integer)) /usr/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/ext.py in array_agg(*arg, **kw) 215 216 """ --> 217 kw['type_'] = ARRAY(functions._type_from_args(arg)) 218 return functions.func.array_agg(*arg, **kw) /usr/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/array.py in __init__(self, item_type, as_tuple, dimensions, zero_indexes) 229 """ 230 if isinstance(item_type, ARRAY): --> 231 raise ValueError("Do not nest ARRAY types; ARRAY(basetype) " 232 "handles multi-dimensional arrays of basetype") 233 if isinstance(item_type, type): ValueError: Do not nest ARRAY types; ARRAY(basetype) handles multi-dimensional arrays of basetype ``` |