The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Allow users to select between null and empty string as default values for text/varchar columns
Joshen Lim02de900aa2aa
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsxindex 9fb22beec30..8c3818e61ce 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx@@ -64,7 +64,7 @@ const ColumnDefaultValue: FC<Props> = ({suggestions={suggestions}onChange={(event: any) => onUpdateField({ defaultValue: event.target.value })}onSelectSuggestion={(suggestion: Suggestion) =>- onUpdateField({ defaultValue: suggestion.name })+ onUpdateField({ defaultValue: suggestion.value })}/>)diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.constants.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.constants.tsindex 7916ac5a681..3e89d80a958 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.constants.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.constants.ts@@ -4,20 +4,36 @@ import { Suggestion } from './ColumnEditor.types'const defaultTimeBasedExpressions: Suggestion[] = [{name: 'now()',+ value: 'now()',description: 'Returns the current date and time',},{name: "(now() at time zone 'utc')",+ value: "(now() at time zone 'utc')",description: 'Returns the current date and time based on the specified timezone',},]+const defaultTextBasedValues: Suggestion[] = [+ {+ name: 'Set as NULL',+ value: null,+ description: 'Set the default value as NULL value',+ },+ {+ name: 'Set as empty string',+ value: '',+ description: 'Set the default value as an empty string',+ },+]+// [Joshen] For now this is a curate mapping, ideally we could look into// using meta-store's extensions to generate this partially on top of vanilla expressionsexport const typeExpressionSuggestions: Dictionary<Suggestion[]> = {uuid: [{name: 'uuid_generate_v4()',+ value: 'uuid_generate_v4()',description: 'Generates a version 4 UUID',},],@@ -25,4 +41,6 @@ export const typeExpressionSuggestions: Dictionary<Suggestion[]> = {timetz: [...defaultTimeBasedExpressions],timestamp: [...defaultTimeBasedExpressions],timestamptz: [...defaultTimeBasedExpressions],+ text: [...defaultTextBasedValues],+ varchar: [...defaultTextBasedValues],}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.types.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.types.tsindex 8ff528a8b8f..3c4e388396e 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.types.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.types.ts@@ -1,4 +1,5 @@export interface Suggestion {name: string+ value: string | nulldescription: string}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsxindex da3c7837bca..f1beab72d82 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx@@ -107,7 +107,7 @@ const Column: FC<Props> = ({className="table-editor-column-type lg:gap-0 "disabled={!isUndefined(column.foreignKey)}onOptionSelect={(format: string) => {- onUpdateColumn({ format, defaultValue: '' })+ onUpdateColumn({ format, defaultValue: null })}}/></div>@@ -131,7 +131,7 @@ const Column: FC<Props> = ({suggestionsWidth={410}onChange={(event: any) => onUpdateColumn({ defaultValue: event.target.value })}onSelectSuggestion={(suggestion: Suggestion) =>- onUpdateColumn({ defaultValue: suggestion.name })+ onUpdateColumn({ defaultValue: suggestion.value })}/></div>