Skip to content

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

Update logic

Joshen Lim24928cc50c3a
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/SpreadsheetImport/SpreadsheetImport.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/SpreadsheetImport/SpreadsheetImport.utils.ts
index 508fa4e5db2..ed3dca9ffcd 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/SpreadsheetImport/SpreadsheetImport.utils.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/SpreadsheetImport/SpreadsheetImport.utils.ts
@@ -122,9 +122,10 @@ export const inferColumnType = (column: string, rows: object[]) => {
// Infer boolean type
if (includes(['true', 'false'], columnData.toString().toLowerCase())) {
- const isAllBoolean = columnDataAcrossRows.every((item: any) =>
- includes(['true', 'false'], (item || '').toString().toLowerCase())
- )
+ const isAllBoolean = columnDataAcrossRows.every((item: any) => {
+ if (item === null) return true
+ else return includes(['true', 'false'], item.toString().toLowerCase())
+ })
if (isAllBoolean) {
return 'boolean'
}
diff --git a/studio/tests/components/Editor/SpreadsheetImport.utils.test.js b/studio/tests/components/Editor/SpreadsheetImport.utils.test.js
index 230fc76df53..11ebfbe75c9 100644
--- a/studio/tests/components/Editor/SpreadsheetImport.utils.test.js
+++ b/studio/tests/components/Editor/SpreadsheetImport.utils.test.js
@@ -35,14 +35,14 @@ describe('SpreadsheedImport.utils: inferColumnType', () => {
const type2 = inferColumnType('isRetired', mockData2)
expect(type2).toBe('boolean')
})
- test('should infer text type for a supposed boolean column if one of the rows has a null value', () => {
+ test('should infer boolean type for a supposed boolean column if one of the rows has a null value', () => {
const mockData3 = [
{ name: 'bob', height: '161.72', isRetired: 'false' },
{ name: 'bob', height: '161.72', isRetired: 'true' },
{ name: 'bob', height: '161.72', isRetired: null },
]
const type3 = inferColumnType('isRetired', mockData3)
- expect(type3).toBe('text')
+ expect(type3).toBe('boolean')
})
test('should infer objects as jsonb types correctly', () => {
const mockData = [{ name: 'bob', metadata: '{}' }]