From 9742e0e72167550e54dfffb133955b0572abbcaa Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Wed, 17 Apr 2024 13:57:27 +0200 Subject: [PATCH] Update the enum listbox to always show schema+enum name. --- .../ColumnEditor/ColumnType.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx index 10de236d7cd..a60355fa81a 100644 --- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx @@ -56,11 +56,15 @@ const ColumnType = ({ let isAvailableInEnums = false if (!isAvailableInPgTypes) { + // this logic is to map the enums. The API for table columns sends only the enums name, without the schema. Since the + // create/update API call for tables expect the enums to be sent with their schemas prefixed. We also want to show + // the prefixed enums in the dropdown so we're changing the value of dropdowns from "enumName" to "schema.enumName" + // on first render const foundByName = enumTypes.find((type) => type.name === value) - if (foundByName && foundByName.schema !== 'public') { - onOptionSelect(foundByName.format) + if (foundByName) { + onOptionSelect(`${foundByName.schema}.${foundByName.name}`) } - const foundByFormat = enumTypes.find((type) => type.format === value) + const foundByFormat = enumTypes.find((type) => `${type.schema}.${type.name}` === value) if (foundByFormat) { isAvailableInEnums = true } @@ -204,15 +208,15 @@ const ColumnType = ({ // @ts-ignore enumTypes.map((enumType) => ( { return }} >
-

{enumType.name}

+

{`${enumType.schema}.${enumType.name}`}

{enumType.comment !== undefined && (

{enumType.comment}

)}