The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fixrow editor bool column value gets set to null if no changes made + conditionally rendering listbox option for bool
Joshen Lim0fcb540f25f4
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsxindex 21206c5394a..cabdefd6fea 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx@@ -196,6 +196,11 @@ const InputField = ({}if (field.format === 'bool') {+ const options = [+ { value: 'true', label: 'TRUE' },+ { value: 'false', label: 'FALSE' },+ ...(field.isNullable ? [{ value: 'null', label: 'NULL' }] : []),+ ]return (<Listboxsize="small"@@ -210,17 +215,16 @@ const InputField = ({else onUpdateField({ [field.name]: value })}}>- <Listbox.Option id="true" key="true" label="TRUE" value="true">- TRUE- </Listbox.Option>- <Listbox.Option id="false" key="false" label="FALSE" value="false">- FALSE- </Listbox.Option>- {field.isNullable && (- <Listbox.Option id="null" key="null" label="NULL" value="null">- NULL+ {options.map((option) => (+ <Listbox.Option+ id={option.value}+ key={option.value}+ label={option.label}+ value={option.value}+ >+ {option.label}</Listbox.Option>- )}+ ))}</Listbox>)}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsxindex 448ee05e791..993da3e6789 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx@@ -55,6 +55,7 @@ const RowEditor = ({if (visible) {setErrors({})const rowFields = generateRowFields(row, selectedTable)+ console.log({ rowFields })setRowFields(rowFields)}}, [visible])@@ -99,6 +100,7 @@ const RowEditor = ({const payload = isNewRecord? generateRowObjectFromFields(rowFields): generateUpdateRowPayload(row, rowFields)+ console.log({ payload })const configuration = { identifiers: {}, rowIdx: -1 }if (!isNewRecord) {diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.tsindex 1d7de98d30d..09c9496550c 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts@@ -3,7 +3,7 @@ import { find, isUndefined, compact, isEqual, omitBy, isNull, isString } from 'limport { Dictionary } from 'components/grid'import type { PostgresTable } from '@supabase/postgres-meta'-import { uuidv4, minifyJSON, tryParseJson } from 'lib/helpers'+import { minifyJSON, tryParseJson } from 'lib/helpers'import { RowField } from './RowEditor.types'import {DATETIME_TYPES,@@ -24,11 +24,16 @@ export const generateRowFields = (const value =isUndefined(row) && TEXT_TYPES.includes(column.format)? null+ : isUndefined(row) && column.format === 'bool' && !column.is_nullable+ ? 'true'+ : isUndefined(row) && column.format === 'bool' && column.is_nullable+ ? 'null': isUndefined(row)? '': DATETIME_TYPES.includes(column.format)? convertPostgresDatetimeToInputDatetime(column.format, row[column.name]): parseValue(row[column.name], column.format)+ console.log(column.name, value)const foreignKey = find(relationships, (relationship) => {return (@@ -78,7 +83,7 @@ export const validateFields = (fields: RowField[]) => {return errors}-const parseValue = (originalValue: string, format: string) => {+const parseValue = (originalValue: any, format: string) => {try {if (originalValue === null || originalValue.length === 0) {return originalValue@@ -87,7 +92,7 @@ const parseValue = (originalValue: string, format: string) => {} else if (typeof originalValue === 'object') {return JSON.stringify(originalValue)} else if (typeof originalValue === 'boolean') {- return (originalValue as any).toString()+ return originalValue.toString()} else {return originalValue}@@ -168,7 +173,8 @@ export const generateRowObjectFromFields = (rowObject[field.name] = tryParseJson(value)}} else if (field.format === 'bool' && value) {- rowObject[field.name] = value === 'true'+ if (value === 'null') rowObject[field.name] = null+ else rowObject[field.name] = value === 'true'} else if (DATETIME_TYPES.includes(field.format)) {// Seconds are missing if they are set to 0 in the HTML input// Need to format that first, before passing to dayjs