The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
adjust logic on setting default value to null when its an empty string
Joshen Limafe35bc3d347
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsxindex 0a69fcdf9ff..5bf033fad3f 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx@@ -1,7 +1,7 @@import { FC, useEffect, useState } from 'react'import { isUndefined, isEmpty } from 'lodash'import { Dictionary } from '@supabase/grid'-import { Checkbox, SidePanel, Space, Input, Divider } from '@supabase/ui'+import { Checkbox, SidePanel, Input } from '@supabase/ui'import {PostgresColumn,PostgresRelationship,@@ -23,6 +23,7 @@ import {generateCreateColumnPayload,generateUpdateColumnPayload,} from './ColumnEditor.utils'+import { TEXT_TYPES } from '../SidePanelEditor.constants'import { ColumnField, CreateColumnPayload, UpdateColumnPayload } from '../SidePanelEditor.types'interface Props {@@ -71,9 +72,8 @@ 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 === '') {+ const isTextBasedColumn = TEXT_TYPES.includes(columnFields.format)+ if (!isTextBasedColumn && changes.defaultValue === '') {changes.defaultValue = null}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsxindex 2e2b260704d..39d7b04071a 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx@@ -27,9 +27,10 @@ import * as Tooltip from '@radix-ui/react-tooltip'import Column from './Column'import InformationBox from 'components/ui/InformationBox'import ForeignKeySelector from '../ForeignKeySelector/ForeignKeySelector'-import { ColumnField } from '../SidePanelEditor.types'import { ImportContent } from './TableEditor.types'import { generateColumnField } from '../ColumnEditor/ColumnEditor.utils'+import { ColumnField } from '../SidePanelEditor.types'+import { TEXT_TYPES } from '../SidePanelEditor.constants'interface Props {table?: Partial<PostgresTable>@@ -91,6 +92,11 @@ const ColumnManagement: FC<Props> = ({const onUpdateColumn = (columnToUpdate: ColumnField, changes: Partial<ColumnField>) => {const updatedColumns = columns.map((column: ColumnField) => {if (column.id === columnToUpdate.id) {+ const isTextBasedColumn = TEXT_TYPES.includes(columnToUpdate.format)+ if (!isTextBasedColumn && changes.defaultValue === '') {+ changes.defaultValue = null+ }+if ('name' in changes && !isUndefined(column.foreignKey)) {const foreignKey: PostgresRelationship = {...column.foreignKey,