Skip to content

Commit

Permalink
'LIMIT' tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontaine committed Sep 7, 2015
1 parent d9d1325 commit 664be78
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package charlatan

import (
"testing"

"github.com/stretchr/testify/require"
)

func okQuery(t *testing.T, q string) {
qry, err := parserFromString(q).Parse()
require.Nil(t, err)
require.NotNil(t, qry)
}

func TestParserParseLimit(t *testing.T) {
for _, s := range []string{
"SELECT x FROM y limit 42",
"SELECT x FROM y starting at 3 limit 42",
"SELECT x FROM y limit 42 starting at 3",
"SELECT x FROM y WHERE z limit 42",
"SELECT x FROM y WHERE z = 2 limit 42",
"SELECT x FROM y WHERE (z = 2) limit 42",
"SELECT x FROM y WHERE (z = 2 && 43) limit 42",
"SELECT x FROM y WHERE z starting at 2 limit 42",
"SELECT x FROM y WHERE z limit 42 starting at 2",
} {
okQuery(t, s)
}
}
4 changes: 3 additions & 1 deletion tests/grammar/grammar.abnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
query = "SELECT" 1*SP select 1*SP
"FROM" 1*SP field *1( 1*SP "WHERE" 1*SP expressions ) *1( 1*SP "STARTING" 1*SP "AT" 1*SP int )
"FROM" 1*SP field *1( 1*SP "WHERE" 1*SP expressions )
*1( 1*SP "STARTING" 1*SP "AT" 1*SP int )
*1( 1*SP "LIMIT" 1*SP int )

select = field *( *SP "," *SP field )

Expand Down

0 comments on commit 664be78

Please sign in to comment.