/** * Every type of every schema, including the row types of tables and views * and the array types, since a column of any schema may use them. */ export declare const TYPES_SQL = "\nselect\n t.oid::int8 as id,\n t.typname as name,\n n.nspname as schema,\n format_type (t.oid, null) as format,\n coalesce(t_enums.enums, '[]') as enums,\n coalesce(t_attributes.attributes, '[]') as attributes,\n obj_description (t.oid, 'pg_type') as comment,\n nullif(t.typrelid::int8, 0) as type_relation_id\nfrom\n pg_type t\n left join pg_namespace n on n.oid = t.typnamespace\n left join (\n select\n enumtypid,\n jsonb_agg(enumlabel order by enumsortorder) as enums\n from\n pg_enum\n group by\n enumtypid\n ) as t_enums on t_enums.enumtypid = t.oid\n left join (\n select\n oid,\n jsonb_agg(\n jsonb_build_object('name', a.attname, 'type_id', a.atttypid::int8)\n order by a.attnum asc\n ) as attributes\n from\n pg_class c\n join pg_attribute a on a.attrelid = c.oid\n where\n c.relkind = 'c' and not a.attisdropped\n group by\n c.oid\n ) as t_attributes on t_attributes.oid = t.typrelid\n where\n (\n t.typrelid = 0\n or (\n select\n c.relkind in ('c', 'r', 'v', 'm', 'p', 'f')\n from\n pg_class c\n where\n c.oid = t.typrelid\n )\n )\n";