Skip to content

Commit

Permalink
Merge pull request #76 from dolthub/zachmu/issue-439
Browse files Browse the repository at this point in the history
Disallow non integer values for limit and offset, allow value args
  • Loading branch information
zachmu committed May 30, 2021
2 parents 7b048c5 + 903f820 commit 7755381
Show file tree
Hide file tree
Showing 3 changed files with 2,527 additions and 2,551 deletions.
30 changes: 25 additions & 5 deletions go/vt/sqlparser/parse_test.go
Expand Up @@ -657,6 +657,10 @@ var (
serializeSelectExprs: true,
}, {
input: "select /* positional argument */ ? from t",
}, {
input: "select /* positional argument */ ? from t limit ?",
output: "select /* positional argument */ :v1 from t limit :v2",
serializeSelectExprs: true,
}, {
input: "select /* multiple positional arguments */ ?, ? from t",
output: "select /* multiple positional arguments */ :v1, :v2 from t",
Expand Down Expand Up @@ -703,9 +707,9 @@ var (
}, {
input: "select /* order by null */ 1 from t order by null",
}, {
input: "select /* limit a */ 1 from t limit a",
input: "select /* limit a */ 1 from t limit 3",
}, {
input: "select /* limit a,b */ 1 from t limit a, b",
input: "select /* limit a,b */ 1 from t limit 4, 5",
}, {
input: "select /* binary unary */ a- -b from t",
output: "select /* binary unary */ a - -b from t",
Expand Down Expand Up @@ -849,7 +853,7 @@ var (
}, {
input: "update /* order */ a set b = 3 order by c desc",
}, {
input: "update /* limit */ a set b = 3 limit c",
input: "update /* limit */ a set b = 3 limit 100",
}, {
input: "update /* bool in update */ a set b = true",
}, {
Expand Down Expand Up @@ -883,7 +887,7 @@ var (
}, {
input: "delete /* order */ from a order by b desc",
}, {
input: "delete /* limit */ from a limit b",
input: "delete /* limit */ from a limit 100",
}, {
input: "delete a from a join b on a.id = b.id where b.name = 'test'",
}, {
Expand Down Expand Up @@ -3693,7 +3697,23 @@ var (
}, {
input: "set session other.@autocommit = true",
output: "invalid user variable declaration `@autocommit` at position 37 near 'true'",
}}
}, {
input: "select * from foo limit -100",
output: "syntax error at position 26 near 'limit'",
}, {
input: "select * from foo limit 1.0",
output: "syntax error at position 28 near '1.0'",
}, {
input: "select * from foo limit 1+1",
output: "syntax error at position 27 near '1'",
}, {
input: "select * from foo limit a",
output: "syntax error at position 26 near 'a'",
}, {
input: "select * from foo limit '100'",
output: "syntax error at position 30 near '100'",
},
}
)

func TestErrors(t *testing.T) {
Expand Down

0 comments on commit 7755381

Please sign in to comment.