fix: List correct enum options when multiple types with same name are present
The schema cache and OpenAPI output would currently list the first found enum with the same name instead of the correct type. One other case where this comes up is when a regular type and an enum type have the same name. For example in the spec fixtures, we have an enum called "bit". Every "bit" type, no matter whether it's that enum or the built-in bit type, will show those enum options in the OpenApi output. Not adding a test, because OpenAPI is supposed to go away in the future anyway.
This commit is contained in:
committed by
Wolfgang Walther
parent
e67461b991
commit
9a40bc266e
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #3093, Nested empty embeds no longer show empty values and are correctly omitted - @laurenceisla
|
- #3093, Nested empty embeds no longer show empty values and are correctly omitted - @laurenceisla
|
||||||
- #3644, Make --dump-schema work with in-database pgrst.db_schemas setting - @wolfgangwalther
|
- #3644, Make --dump-schema work with in-database pgrst.db_schemas setting - @wolfgangwalther
|
||||||
- #3644, Show number of timezones in schema cache load report - @wolfgangwalther
|
- #3644, Show number of timezones in schema cache load report - @wolfgangwalther
|
||||||
|
- #3644, List correct enum options in OpenApi output when multiple types with same name are present - @wolfgangwalther
|
||||||
|
|
||||||
## [12.2.1] - 2024-06-27
|
## [12.2.1] - 2024-06-27
|
||||||
|
|
||||||
|
|||||||
@@ -647,7 +647,7 @@ tablesSqlQuery pgVer =
|
|||||||
information_schema._pg_truetypid(a.*, t.*),
|
information_schema._pg_truetypid(a.*, t.*),
|
||||||
information_schema._pg_truetypmod(a.*, t.*)
|
information_schema._pg_truetypmod(a.*, t.*)
|
||||||
)::integer AS character_maximum_length,
|
)::integer AS character_maximum_length,
|
||||||
COALESCE(bt.typname, t.typname)::name AS udt_name,
|
COALESCE(bt.oid, t.oid) AS base_type,
|
||||||
a.attnum::integer AS position
|
a.attnum::integer AS position
|
||||||
FROM pg_attribute a
|
FROM pg_attribute a
|
||||||
LEFT JOIN pg_description AS d
|
LEFT JOIN pg_description AS d
|
||||||
@@ -691,14 +691,13 @@ tablesSqlQuery pgVer =
|
|||||||
FROM columns info
|
FROM columns info
|
||||||
LEFT OUTER JOIN (
|
LEFT OUTER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
n.nspname AS s,
|
e.enumtypid,
|
||||||
t.typname AS n,
|
|
||||||
array_agg(e.enumlabel ORDER BY e.enumsortorder) AS vals
|
array_agg(e.enumlabel ORDER BY e.enumsortorder) AS vals
|
||||||
FROM pg_type t
|
FROM pg_type t
|
||||||
JOIN pg_enum e ON t.oid = e.enumtypid
|
JOIN pg_enum e ON t.oid = e.enumtypid
|
||||||
JOIN pg_namespace n ON n.oid = t.typnamespace
|
JOIN pg_namespace n ON n.oid = t.typnamespace
|
||||||
GROUP BY s,n
|
GROUP BY enumtypid
|
||||||
) AS enum_info ON info.udt_name = enum_info.n
|
) AS enum_info ON info.base_type = enum_info.enumtypid
|
||||||
WHERE info.table_schema NOT IN ('pg_catalog', 'information_schema')
|
WHERE info.table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||||
GROUP BY info.table_schema, info.table_name
|
GROUP BY info.table_schema, info.table_name
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user