mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 06:39:09 +03:00
Fix CSV import for files with no rows, just headers (#4160)
This commit is contained in:
1 parent
434a16b92c
commit
b72e80afb4
2 files changed
+5
-1
No files matched your search
+4
@@ -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])
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user