You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't handle postgres table with geometry column because of PR #151.
I think we should modify SCHEMA_QUERY. When c.data_type = 'USER-DEFINED', return t.typname.
WITH custom_type_details AS (
SELECTt.typname,
t.typtype,
CASE
WHEN t.typtype='e' THEN
jsonb_build_object(
'type', 'enum',
'values', (
SELECT jsonb_agg(e.enumlabelORDER BYe.enumsortorder)
FROM pg_enum e
WHEREe.enumtypid=t.oid
)
)
WHEN t.typtype='c' THEN
jsonb_build_object(
'type', 'composite',
'attributes', (
SELECT jsonb_agg(
jsonb_build_object(
'name', a.attname,
'type', pg_catalog.format_type(a.atttypid, a.atttypmod)
)
ORDER BYa.attnum
)
FROM pg_attribute a
WHEREa.attrelid=t.typrelidANDa.attnum>0AND NOT a.attisdropped
)
)
END as type_details
FROM pg_type t
WHEREt.typnamespace= (SELECToidFROM pg_namespace WHERE nspname = $1)
)
SELECTc.column_name,
CASE
WHEN c.data_type='USER-DEFINED' THEN
CASE
WHEN t.typtype='e' THEN 'enum'
WHEN t.typtype='c' THEN 'composite'
ELSE t.typname
END
WHEN c.data_type='ARRAY' THEN
'array'
ELSE pg_catalog.format_type(a.atttypid, a.atttypmod)
END as data_type,
c.is_nullable,
CASE
WHEN c.data_type='ARRAY' THEN
jsonb_build_object(
'type', 'array',
'element_type', (
SELECTpg_catalog.format_type(et.oid, a.atttypmod)
FROM pg_type t
JOIN pg_type et ONt.typelem=et.oidWHEREt.typname=c.udt_name
)
)
ELSE td.type_details
END as type_details
FROMinformation_schema.columns c
LEFT JOIN custom_type_details td ONtd.typname=c.udt_nameLEFT JOIN pg_type t ONt.typname=c.udt_nameLEFT JOIN pg_attribute a ONa.attrelid= (
SELECToidFROM pg_class
WHERE relname =c.table_nameAND relnamespace = (
SELECToidFROM pg_namespace
WHERE nspname =c.table_schema
)
)
ANDa.attname=c.column_nameWHEREc.table_schema= $1ANDc.table_name= $2ORDER BYc.ordinal_position;
column_name | data_type | is_nullable | type_details
-----------------+------------------------+-------------+-------------------------------------------------------
id | integer | NO |
name | character varying(100) | NO |
chinese | character varying(100) | NO |
adcode | character varying(20) | NO |
center | array | NO | {"type": "array", "element_type": "double precision"}
centroid | array | NO | {"type": "array", "element_type": "double precision"}
geom | geometry | NO |
children_num | integer | NO |
level | character varying(100) | NO |
parent | character varying(20) | NO |
acroutes | array | NO | {"type": "array", "element_type": "integer"}
centro_id | array | YES | {"type": "array", "element_type": "double precision"}
bound | text | YES |
simplified_geom | geometry | YES |
The text was updated successfully, but these errors were encountered:
xhwhis
changed the title
postgres table can't get schema with geometry column
can't handle postgres table with geometry column
Nov 29, 2024
I'm guessing geometry is being represented as a composite type? Otherwise we already return t.typname
No. geometry is being represented as a base type. So can we change to this sql?
WHEN c.data_type='USER-DEFINED' THEN
CASE
WHEN t.typtype='e' THEN 'enum'
WHEN t.typtype='c' THEN 'composite'
WHEN t.typtype='b' THEN t.typname
ELSE c.data_type
END
I can't handle postgres table with geometry column because of PR #151.
I think we should modify
SCHEMA_QUERY
. Whenc.data_type = 'USER-DEFINED'
, returnt.typname
.The text was updated successfully, but these errors were encountered: