Skip to content

Commit

Permalink
document/fix(?) parsing of 1e-/*test*/-5 which reproduces incorrectly
Browse files Browse the repository at this point in the history
very much related to cockroachdb#1810.
  • Loading branch information
tbg committed Jul 25, 2015
1 parent 0b4ea4d commit a21f02c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sql/parser/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ func (node IntVal) String() string {
type NumVal string

func (node NumVal) String() string {
return string(node)
s := string(node)
if l := len(s); l > 0 && s[l-1] == '-' {
s += " "
}
return s
}

// BoolVal represents a boolean.
Expand Down
2 changes: 2 additions & 0 deletions sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ func TestParse2(t *testing.T) {
`SELECT *, - -5`},
{"SELECT -\n-5",
`SELECT - -5`},
{"SELECT 1e-\n-1",
`SELECT 1e- -1`},
}
for _, d := range testData {
stmts, err := Parse(d.sql)
Expand Down

0 comments on commit a21f02c

Please sign in to comment.