The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix incorrect parsing of column default value when default value is an expression that is a combination of values
Joshen Lim95be697ea72b
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.tsindex df51a368199..f8af6b0ad1b 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts@@ -199,6 +199,19 @@ const formatArrayToPostgresArray = (arrayString: string) => {export const unescapeLiteral = (value: string) => {if (!value) return value+ // Handle combinations - this is really not the best solution imo+ // It's a log(n) attempt to strip off the ::type strings+ if (value.includes('||')) {+ const formattedValue = []+ let found = false+ for (let i = 0; i < value.length; i++) {+ if (value[i] === ':') found = true+ if (((value[i] === ' ' || value[i] === ')') && found) || i === value.length - 1) found = false+ if (!found) formattedValue.push(value[i])+ }+ return formattedValue.join('')+ }+const splits = value.split("'::")if (splits.length <= 1) return valuediff --git a/studio/package.json b/studio/package.jsonindex b66f0a8c9fe..938538fb905 100644--- a/studio/package.json+++ b/studio/package.json@@ -28,7 +28,7 @@"@supabase/react-data-grid": "^7.1.0-beta.7","@supabase/shared-types": "^0.1.24","@supabase/supabase-js": "^1.36.0-next.9",- "@supabase/ui": "0.37.0-alpha.71",+ "@supabase/ui": "0.37.0-alpha.73","ajv": "^8.6.3","analytics-node": "^3.5.0","awesome-debounce-promise": "^2.1.0",diff --git a/studio/tests/components/Editor/ColumnEditor.utils.test.js b/studio/tests/components/Editor/ColumnEditor.utils.test.jsindex 91de069269e..a9a63dc1887 100644--- a/studio/tests/components/Editor/ColumnEditor.utils.test.js+++ b/studio/tests/components/Editor/ColumnEditor.utils.test.js@@ -41,6 +41,19 @@ describe('ColumnEditor.utils: unescapeLiteral', () => {const value = unescapeLiteral(mockInput)expect(value).toStrictEqual("(now() at time zone 'utc')")})+ test('should return expressions that combine values properly', () => {+ const mockInput1 = "('hi_'::text || uuid_generate_v4())"+ const value1 = unescapeLiteral(mockInput1)+ expect(value1).toStrictEqual("('hi_' || uuid_generate_v4())")++ const mockInput2 = "(('hi'::text || 'bye'::text) || 'hello'::text)"+ const value2 = unescapeLiteral(mockInput2)+ expect(value2).toStrictEqual("(('hi' || 'bye') || 'hello')")++ const mockInput3 = "(uuid_generate_v4() || 'helo'::text)"+ const value3 = unescapeLiteral(mockInput3)+ expect(value3).toStrictEqual("(uuid_generate_v4() || 'helo')")+ })test('should return json object properly', () => {const mockInput = `'{\"version\": 10, \"dimensions\": {\"width\": 50, \"height\": 20}}'::jsonb`const value = unescapeLiteral(mockInput)