Skip to content

Commit 6ae484d

Browse files
committed
Bug fix: Don't crash the type guesser when we find columns with no values in
1 parent ae860d3 commit 6ae484d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/importer/src/dudk/backend.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ exports.SessionGuessTypes = (sid, range) => {
653653

654654
// Initialise state, that we will refine as we go
655655
for (let col=0;col<columns;col++) {
656-
guesses[col] = {safeTpes: undefined,
656+
guesses[col] = {safeTypes: undefined,
657657
maybeTypes: undefined,
658658
full:true}; // This is unset if we find a blank/missing
659659
// value
@@ -725,11 +725,17 @@ exports.SessionGuessTypes = (sid, range) => {
725725
}
726726

727727
// Now we must go back through the guesses and remove any safe types/formats
728-
// from the maybe types/formats, so "maybe" ONLY contains options that are
728+
// from the maybe types/formats, so "maybe" ONLY contains saoptions that are
729729
// valid for some *but not all* values; every safe type/format will be listed
730730
// as a maybe type/format due to the process used above.
731731

732+
// IN this pass, we also look for any columns that never got any guesses,
733+
// because they're entirely blank - these will still have undefined for
734+
// safeTypes and maybeTypes, and we should swap those for empty arrays.
735+
732736
guesses.forEach((colGuesses) => {
737+
if(!colGuesses.safeTypes) colGuesses.safeTypes = [];
738+
if(!colGuesses.maybeTypes) colGuesses.maybeTypes = [];
733739
let maybeTypes = colGuesses.maybeTypes;
734740
colGuesses.safeTypes.forEach((safeFormats, typeName) => {
735741
if(safeFormats) {

0 commit comments

Comments
 (0)