Skip to content

Commit

Permalink
Fixed parsing issue when dealing with functional calls with multiple …
Browse files Browse the repository at this point in the history
…arguments
  • Loading branch information
mpscholten committed Jan 6, 2022
1 parent ef8150e commit 4814fd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IHP/IDE/SchemaDesigner/Parser.hs
Expand Up @@ -429,7 +429,7 @@ intExpr = IntExpression <$> Lexer.decimal
callExpr :: Parser Expression
callExpr = do
func <- qualifiedIdentifier
args <- between (char '(') (char ')') (expression `sepBy` char ',')
args <- between (char '(') (char ')') (expression `sepBy` (char ',' >> space))
space
pure (CallExpression func args)

Expand Down
10 changes: 10 additions & 0 deletions Test/IDE/SchemaDesigner/ParserSpec.hs
Expand Up @@ -720,6 +720,16 @@ COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UU
, check = Just (ExistsExpression (SelectExpression (Select {columns = [IntExpression 1], from = DotExpression (VarExpression "public") "projects", whereClause = EqExpression (DotExpression (VarExpression "projects") "id") (DotExpression (VarExpression "migrations") "project_id")})))
}

it "should parse a call expression with multiple arguments" do
let sql = cs [plain|ALTER TABLE a ADD CONSTRAINT source CHECK (num_nonnulls(a, b, c) = 1);|]
parseSql sql `shouldBe` AddConstraint
{ tableName = "a"
, constraint = CheckConstraint
{ name = Just "source"
, checkExpression = EqExpression (CallExpression "num_nonnulls" [VarExpression "a",VarExpression "b",VarExpression "c"]) (IntExpression 1)
}
}

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

0 comments on commit 4814fd0

Please sign in to comment.