Skip to content

Commit

Permalink
fix(bulk): fallback columnDelimtier to COMMA
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Dec 16, 2024
1 parent 1b02e4a commit 1db77b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bulkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ export async function detectDelimiter(filePath: string): Promise<ColumnDelimiter
}
}

const columDelimiter = delimiterMap.get(detectedDelimiter ?? '');
// default to `COMMA` if no delimiter was found in the CSV file (1 column)
const columDelimiter = delimiterMap.get(detectedDelimiter ?? ',');

if (columDelimiter === undefined) {
throw new SfError(`Failed to detect column delimiter used in ${filePath}.`);
Expand Down
1 change: 1 addition & 0 deletions test/bulkUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('bulkUtils', () => {
expect(await detectDelimiter('./test/test-files/csv/backquote.csv')).to.equal('BACKQUOTE');
expect(await detectDelimiter('./test/test-files/csv/caret.csv')).to.equal('CARET');
expect(await detectDelimiter('./test/test-files/csv/comma.csv')).to.equal('COMMA');
expect(await detectDelimiter('./test/test-files/csv/single-column.csv')).to.equal('COMMA');
expect(await detectDelimiter('./test/test-files/csv/comma_wrapped_values.csv')).to.equal('COMMA');
expect(await detectDelimiter('./test/test-files/csv/pipe.csv')).to.equal('PIPE');
expect(await detectDelimiter('./test/test-files/csv/semicolon.csv')).to.equal('SEMICOLON');
Expand Down
11 changes: 11 additions & 0 deletions test/test-files/csv/single-column.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NAME
account Upsert #0
account Upsert #1
account Upsert #2
account Upsert #3
account Upsert #4
account Upsert #5
account Upsert #6
account Upsert #7
account Upsert #8
account Upsert #9

0 comments on commit 1db77b0

Please sign in to comment.