--- /dev/null
+.. change::
+ :tags: usecase, postgresql, reflection
+ :tickets: 9838
+
+ Cast ``NAME`` columns to ``TEXT`` when using ``ARRAY_AGG`` in PostgreSQL
+ reflection. This seems to improve compatibility with some PostgreSQL
+ derivatives that may not support aggregations on the ``NAME`` type.
select(
attr_sq.c.conrelid,
sql.func.array_agg(
- aggregate_order_by(attr_sq.c.attname, attr_sq.c.ord)
+ # NOTE: cast since some postgresql derivatives may
+ # not support array_agg on the name type
+ aggregate_order_by(
+ attr_sq.c.attname.cast(TEXT), attr_sq.c.ord
+ )
).label("cols"),
attr_sq.c.conname,
sql.func.min(attr_sq.c.description).label("description"),
),
# NOTE: need to cast this since attname is of type "name"
# that's limited to 63 bytes, while pg_get_indexdef
- # returns "text" so it may get cut
- else_=sql.cast(pg_catalog.pg_attribute.c.attname, TEXT()),
+ # returns "text" so its output may get cut
+ else_=pg_catalog.pg_attribute.c.attname.cast(TEXT),
).label("element"),
(idx_sq.c.attnum == 0).label("is_expr"),
)
pg_catalog.pg_enum.c.enumtypid,
sql.func.array_agg(
aggregate_order_by(
- pg_catalog.pg_enum.c.enumlabel,
+ # NOTE: cast since some postgresql derivatives may
+ # not support array_agg on the name type
+ pg_catalog.pg_enum.c.enumlabel.cast(TEXT),
pg_catalog.pg_enum.c.enumsortorder,
)
).label("labels"),
pg_catalog.pg_constraint.c.oid, True
)
).label("condefs"),
- sql.func.array_agg(pg_catalog.pg_constraint.c.conname).label(
- "connames"
- ),
+ sql.func.array_agg(
+ # NOTE: cast since some postgresql derivatives may
+ # not support array_agg on the name type
+ pg_catalog.pg_constraint.c.conname.cast(TEXT)
+ ).label("connames"),
)
# The domain this constraint is on; zero if not a domain constraint
.where(pg_catalog.pg_constraint.c.contypid != 0)