Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 91b762b

Browse files
authored
Merge pull request #35 from safareli/parse
Fix parsing of non-lowercase literals
2 parents b623cc0 + 9239ed4 commit 91b762b

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

src/SqlSquared/Parser.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ literal = withToken "literal" case _ of
432432
Lit (Integer i) → pure $ embed $ Sig.Literal $ EJ.Integer i
433433
Lit (Decimal d) → pure $ embed $ Sig.Literal $ EJ.Decimal d
434434
Kw s
435-
| s == "null" → pure $ embed $ Sig.Literal $ EJ.Null
436-
| s == "true" → pure $ embed $ Sig.Literal $ EJ.Boolean true
437-
| s == "false" → pure $ embed $ Sig.Literal $ EJ.Boolean false
435+
| S.toLower s == "null" → pure $ embed $ Sig.Literal $ EJ.Null
436+
| S.toLower s == "true" → pure $ embed $ Sig.Literal $ EJ.Boolean true
437+
| S.toLower s == "false" → pure $ embed $ Sig.Literal $ EJ.Boolean false
438438
t → P.fail (printToken t)
439439

440440
stringLiteral m. Monad m P.ParserT TokenStream m String

test/src/Gen.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ module Test.Gen where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff, foreachE)
5+
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE)
77
import Control.Monad.Eff.Exception (EXCEPTION)
88
import Control.Monad.Eff.Random (RANDOM)
9-
import Data.Array ((..))
109
import Data.Either as E
1110
import SqlSquared (SqlQuery, arbitrarySqlQueryOfSize, decodeJsonQuery, encodeJsonQuery, printQuery, tokenize)
1211
import Test.QuickCheck ((<?>))

test/src/Parse.purs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,42 @@ testSuite = suite "parsers" do
5151

5252
testSuite1 e. TestSuite (testOutput Console.TESTOUTPUT | e)
5353
testSuite1 = do
54+
parseSucc """
55+
a := 1; SELECT * FROM `/test`
56+
"""
57+
58+
parseSucc """
59+
SELECT * FROM `/test`
60+
"""
61+
62+
parseSucc """
63+
SELECT * FROM `/smallZips.json` WHERE city IS NOT "foo"
64+
"""
65+
66+
parseSucc """
67+
SELECT * FROM `/smallZips.json` WHERE city IS null
68+
"""
69+
70+
parseSucc """
71+
SELECT * FROM `/smallZips.json` WHERE city IS true
72+
"""
73+
74+
parseSucc """
75+
SELECT * FROM `/smallZips.json` WHERE city IS TRUE
76+
"""
77+
78+
parseSucc """
79+
SELECT * FROM `/smallZips.json` WHERE city IS NULL
80+
"""
81+
82+
parseSucc """
83+
SELECT * FROM `/smallZips.json` WHERE city IS NOT NULL
84+
"""
85+
86+
parseSucc """
87+
SELECT * FROM `/smallZips.json` WHERE city IS NOT null
88+
"""
89+
5490
parseSucc """
5591
select a from `/f` where b is not between 1 and (2..3)
5692
"""

0 commit comments

Comments
 (0)