Skip to content

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

Only show set to null action if column is nullable

Joshen Lim4962b4e78e4c
diff --git a/studio/components/grid/components/editor/TextEditor.tsx b/studio/components/grid/components/editor/TextEditor.tsx
index d80a4953a8b..53273c2d4d5 100644
--- a/studio/components/grid/components/editor/TextEditor.tsx
+++ b/studio/components/grid/components/editor/TextEditor.tsx
@@ -7,6 +7,7 @@ import { Button, Popover } from 'ui'
export function TextEditor<TRow, TSummaryRow = unknown>({
row,
column,
+ isNullable,
onRowChange,
}: EditorProps<TRow, TSummaryRow>) {
const state = useTrackedState()
@@ -60,9 +61,11 @@ export function TextEditor<TRow, TSummaryRow = unknown>({
</div>
</div>
<div className="space-y-1">
- <Button type="default" size="tiny" onClick={() => saveChanges(null)}>
- Set to NULL
- </Button>
+ {isNullable && (
+ <Button type="default" size="tiny" onClick={() => saveChanges(null)}>
+ Set to NULL
+ </Button>
+ )}
</div>
</div>
</BlockKeys>
diff --git a/studio/components/grid/utils/gridColumns.tsx b/studio/components/grid/utils/gridColumns.tsx
index 29e9e958d5b..7671f625470 100644
--- a/studio/components/grid/utils/gridColumns.tsx
+++ b/studio/components/grid/utils/gridColumns.tsx
@@ -130,7 +130,7 @@ function getColumnEditor(
return NumberEditor
}
case 'text': {
- return TextEditor
+ return (p: any) => <TextEditor {...p} isNullable={columnDefinition.isNullable} />
}
default: {
return undefined
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
index 5c3b2e6fead..065831046cc 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
@@ -128,9 +128,9 @@ const InputField: FC<Props> = ({
value={field.value ?? ''}
placeholder={
field.defaultValue === null
- ? ''
+ ? 'NULL'
: typeof field.defaultValue === 'string' && field.defaultValue.length === 0
- ? 'Default: Empty string'
+ ? 'EMPTY'
: `Default: ${field.defaultValue}`
}
onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}