diff --git a/src/parser/insert-values-parser.ts b/src/parser/insert-values-parser.ts index 10f9a64f2..8540fe8ee 100644 --- a/src/parser/insert-values-parser.ts +++ b/src/parser/insert-values-parser.ts @@ -80,7 +80,10 @@ function parseColumnNamesAndIndexes( const cols = Object.keys(row) for (const col of cols) { - if (!columns.has(col)) { + const shouldIncludeColumnWithUndefined = + rows.length > 1 && rows.some((row) => row[col] !== undefined) + + if (!columns.has(col) && shouldIncludeColumnWithUndefined) { columns.set(col, columns.size) } }