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

Commit b5114d7

Browse files
authored
Fix inner join parsing (#26)
* Fix inner join parsing * More join fixes
1 parent 041be0b commit b5114d7

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/SqlSquared/Parser.purs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,17 +717,22 @@ stdJoinRelation
717717
stdJoinRelation = PC.try do
718718
joinType ←
719719
(Sig.LeftJoin
720-
<$ keyword "left")
720+
<$ keyword "left"
721+
<* (PC.optional $ keyword "outer"))
721722
<|>
722723
(Sig.RightJoin
723-
<$ keyword "right")
724+
<$ keyword "right"
725+
<* (PC.optional $ keyword "outer"))
724726
<|>
725-
(Sig.FullJoin
727+
(PC.try $ Sig.FullJoin
726728
<$ (PC.optional $ keyword "full")
727-
<* (PC.optional $ keyword "outer"))
728-
<|>
729+
<* keyword "outer")
730+
<|>
731+
(Sig.FullJoin
732+
<$ keyword "full")
733+
<|>
729734
(Sig.InnerJoin
730-
<$ keyword "inner")
735+
<$ (PC.optional $ keyword "inner"))
731736
_ ← keyword "join"
732737
right ← simpleRelation
733738
_ ← keyword "on"

test/src/Parse.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ select 12
4747
, E.Right """select :where"""
4848
, E.Right """foo.`_id`"""
4949
, E.Left """foo._id"""
50+
, E.Right """select * from foo JOIN bar on baz"""
51+
, E.Right """select * from foo FULL JOIN bar on baz"""
52+
, E.Right """select * from foo FULL OUTER JOIN bar on baz"""
53+
, E.Right """select * from foo INNER JOIN bar on baz"""
54+
, E.Right """select * from foo LEFT OUTER JOIN bar on baz"""
55+
, E.Right """select * from foo LEFT JOIN bar on baz"""
56+
, E.Right """select * from foo RIGHT OUTER JOIN bar on baz"""
57+
, E.Right """select * from foo RIGHT JOIN bar on baz"""
5058
]
5159

5260
testSuite e. TestSuite (testOutput Console.TESTOUTPUT | e)

0 commit comments

Comments
 (0)