Skip to content

Commit 139c43c

Browse files
maumuellerbingmann
authored andcommitted
Fix error in detection of double type.
1 parent 3555ada commit 139c43c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/fieldset.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ FieldSet::fieldtype FieldSet::detect(const std::string& str)
8585
}
8686
}
8787
}
88+
// skip double exponent and iterate over digits
89+
else if (it != str.end() && (*it == 'e' || *it == 'E'))
90+
{
91+
++it;
92+
93+
// skip sign
94+
if (it != str.end() && (*it == '+' || *it == '-')) ++it;
95+
96+
// iterate over digits
97+
while (it != str.end() && isdigit(*it)) ++it;
98+
99+
if (it == str.end() && it != str.begin()) {
100+
return T_DOUBLE;
101+
}
102+
103+
}
88104

89105
return T_VARCHAR;
90106
}
@@ -95,6 +111,7 @@ void FieldSet::check_detect()
95111
assert( detect("1234") == T_INTEGER );
96112
assert( detect("1234.3") == T_DOUBLE );
97113
assert( detect(".3e-3") == T_DOUBLE );
114+
assert( detect("5e-05") == T_DOUBLE );
98115
assert( detect("1234,3") == T_VARCHAR );
99116
assert( detect("sdfdf") == T_VARCHAR );
100117
}

0 commit comments

Comments
 (0)