diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.utils.ts index b7a0e4410e1..841bfc65d0d 100644 --- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.utils.ts +++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.utils.ts @@ -62,6 +62,10 @@ export const inferColumnType = (column: string, rows: object[]) => { // General strategy is to check the first row first, before checking across all the rows // to ensure uniformity in data type. Thinking we do this as an optimization instead of // checking all the rows up front. + + // If there are no rows to infer for, default to text + if (rows.length === 0) return 'text' + const columnData = (rows[0] as any)[column] const columnDataAcrossRows = rows.map((row: object) => (row as any)[column]) diff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.ts index 68491e1b6c0..68c1d5ce370 100644 --- a/studio/stores/pgmeta/MetaStore.ts +++ b/studio/stores/pgmeta/MetaStore.ts @@ -393,7 +393,7 @@ export default class MetaStore implements IMetaStore { // If the user is importing data via a spreadsheet if (!isUndefined(importContent)) { - if (importContent.file) { + if (importContent.file && importContent.rowCount > 0) { // Via a CSV file const { error }: any = await this.insertRowsViaSpreadsheet( importContent.file,