Skip to content

Commit

Permalink
Support lowercased SELECT expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jan 14, 2022
1 parent 3969ab9 commit 6aec203
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions IHP/IDE/SchemaDesigner/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ textExpr' = cs <$> do

selectExpr :: Parser Expression
selectExpr = do
lexeme "SELECT"
symbol' "SELECT"
columns <- expression `sepBy` (char ',' >> space)
lexeme "FROM"
symbol' "FROM"
from <- expression
lexeme "WHERE"
symbol' "WHERE"
whereClause <- expression
pure (SelectExpression Select { .. })

Expand Down
3 changes: 3 additions & 0 deletions Test/IDE/SchemaDesigner/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UU
it "should parse negative DoubleExpression's" do
parseExpression "-1.337" `shouldBe` (DoubleExpression (-1.337))

it "should parse lower-cased SELECT expressions" do
parseExpression "(select company_id from users where id = ihp_user_id())" `shouldBe` SelectExpression (Select {columns = [VarExpression "company_id"], from = VarExpression "users", whereClause = EqExpression (VarExpression "id") (CallExpression "ihp_user_id" [])})

col :: Column
col = Column
{ name = ""
Expand Down

0 comments on commit 6aec203

Please sign in to comment.