Skip to content

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

fix: Set the default value for boolean fields when creating a new row (#17844)

Ivan Vasilov276b32f3312a
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
index 0e3c82dd983..22dad69e460 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
@@ -25,7 +25,7 @@ export const generateRowFields = (
isUndefined(row) && TEXT_TYPES.includes(column.format)
? null
: isUndefined(row) && column.format === 'bool' && !column.is_nullable
- ? 'true'
+ ? column.default_value
: isUndefined(row) && column.format === 'bool' && column.is_nullable
? 'null'
: isUndefined(row)
@@ -188,7 +188,17 @@ export const generateRowObjectFromFields = (
rowObject[field.name] = value
}
})
- return includeNullProperties ? rowObject : omitBy(rowObject, isNull)
+ if (includeNullProperties) {
+ return rowObject
+ } else {
+ return omitBy(rowObject, (v, k) => {
+ const field = fields.find((f) => f.name === k)
+ if (field && field.isNullable) {
+ return false
+ }
+ return isNull(v)
+ })
+ }
}
export const generateUpdateRowPayload = (originalRow: any, field: RowField[]) => {