Skip to content

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

Table editor cell enum dropdown, dont show null option if column is not nullable (#20474)

Joshen Lim73c134ceb4a5
diff --git a/apps/studio/components/grid/components/editor/SelectEditor.tsx b/apps/studio/components/grid/components/editor/SelectEditor.tsx
index d092b16cff3..dcb7705a17f 100644
--- a/apps/studio/components/grid/components/editor/SelectEditor.tsx
+++ b/apps/studio/components/grid/components/editor/SelectEditor.tsx
@@ -5,6 +5,7 @@ import { useTrackedState } from 'components/grid/store'
interface SelectEditorProps<TRow, TSummaryRow = unknown>
extends RenderEditCellProps<TRow, TSummaryRow> {
+ isNullable?: boolean
options: { label: string; _value: string }[]
}
@@ -14,6 +15,7 @@ export function SelectEditor<TRow, TSummaryRow = unknown>({
onRowChange,
onClose,
options,
+ isNullable,
}: SelectEditorProps<TRow, TSummaryRow>) {
const state = useTrackedState()
const gridColumn = state.gridColumns.find((x) => x.name == column.key)
@@ -46,7 +48,7 @@ export function SelectEditor<TRow, TSummaryRow = unknown>({
onChange={onChange}
onBlur={onBlur}
>
- <Select.Option value="">NULL</Select.Option>
+ {isNullable && <Select.Option value="">NULL</Select.Option>}
{options.map(({ label, _value }) => (
<Select.Option key={_value} value={_value} selected={_value === value}>
{label}
diff --git a/apps/studio/components/grid/utils/gridColumns.tsx b/apps/studio/components/grid/utils/gridColumns.tsx
index 05b2d0480ae..5498af8a2d0 100644
--- a/apps/studio/components/grid/utils/gridColumns.tsx
+++ b/apps/studio/components/grid/utils/gridColumns.tsx
@@ -148,7 +148,9 @@ function getCellEditor(
return { label: x, value: x }
})
// eslint-disable-next-line react/display-name
- return (p: any) => <SelectEditor {...p} options={options} />
+ return (p: any) => (
+ <SelectEditor {...p} options={options} isNullable={columnDefinition.isNullable} />
+ )
}
case 'array':
case 'json': {