Skip to content

Commit

Permalink
Merge pull request #6864 from bdarnell/parse-numeric
Browse files Browse the repository at this point in the history
sql: Parse "e" case-insensitively in numeric constants
  • Loading branch information
bdarnell committed May 24, 2016
2 parents 45f7fd5 + eae4a39 commit 51e30da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql/parser/constant.go
Expand Up @@ -234,7 +234,7 @@ func (expr *NumVal) ResolveAsType(typ Datum) (Datum, error) {
// TODO(nvanbenschoten) Handling e will not be necessary once the TODO about the
// OrigString workaround from above is addressed.
eScale := inf.Scale(0)
if eIdx := strings.IndexRune(s, 'e'); eIdx != -1 {
if eIdx := strings.IndexAny(s, "eE"); eIdx != -1 {
eInt, err := strconv.ParseInt(s[eIdx+1:], 10, 32)
if err != nil {
return nil, fmt.Errorf("could not evaluate %v as Datum type DDecimal from "+
Expand Down
2 changes: 1 addition & 1 deletion sql/parser/constant_test.go
Expand Up @@ -65,7 +65,7 @@ func TestNumericConstantAvailableTypes(t *testing.T) {
}

// Check available types.
c := &NumVal{Value: val}
c := &NumVal{Value: val, OrigString: test.str}
avail := c.AvailableTypes()
if !reflect.DeepEqual(avail, test.avail) {
t.Errorf("%d: expected the available type set %v for %v, found %v",
Expand Down

0 comments on commit 51e30da

Please sign in to comment.