Skip to content

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

Convert empty string to null before saving

Terry Suttond0b2ab7b4c5c
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
index a6677cd53a1..0a69fcdf9ff 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
@@ -71,6 +71,12 @@ const ColumnEditor: FC<Props> = ({
}, [visible])
const onUpdateField = (changes: Partial<ColumnField>) => {
+ // An <input> can't have null as its value, so we need to use ''
+ // and convert this '' to null before saving it
+ if (changes.defaultValue === '') {
+ changes.defaultValue = null
+ }
+
const updatedColumnFields = { ...columnFields, ...changes } as ColumnField
setColumnFields(updatedColumnFields)
updateEditorDirty()