Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add temp fix in unescapeLiteral for nextval

Joshen Limdf7f056257ab
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
index 61720ea7157..7385ef0a5a1 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
@@ -220,6 +220,11 @@ export const unescapeLiteral = (value: string) => {
return `${splits[0].toLowerCase()}')`
}
+ // Handle nextval
+ if (value.toLowerCase().includes('nextval')) {
+ return `${splits[0]}')`
+ }
+
// Handle json
if (value.toLowerCase().includes('json')) {
return splits[0].slice(1)
diff --git a/studio/tests/components/Editor/ColumnEditor.utils.test.js b/studio/tests/components/Editor/ColumnEditor.utils.test.js
index 6137cd71edc..c147fa07a13 100644
--- a/studio/tests/components/Editor/ColumnEditor.utils.test.js
+++ b/studio/tests/components/Editor/ColumnEditor.utils.test.js
@@ -1,6 +1,11 @@
import { unescapeLiteral } from 'components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils'
describe('ColumnEditor.utils: unescapeLiteral', () => {
+ test('should return varchar properly', () => {
+ const mockInput = `nextval('"Test_id_seq"'::regclass)`
+ const value = unescapeLiteral(mockInput)
+ expect(value).toStrictEqual(`nextval('"Test_id_seq"')`)
+ })
test('should return varchar properly', () => {
const mockInput = "'potato'::character varying"
const value = unescapeLiteral(mockInput)