-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std/parsesql: Fix JOIN parsing (#22890)
This commit fixes/adds tests for and fixes several issues with `JOIN` operator parsing: - For OUTER joins, LEFT | RIGHT | FULL specifier is not optional ```nim doAssertRaises(SqlParseError): discard parseSql(""" SELECT id FROM a OUTER JOIN b ON a.id = b.id """) ``` - For NATURAL JOIN and CROSS JOIN, ON and USING clauses are forbidden ```nim doAssertRaises(SqlParseError): discard parseSql(""" SELECT id FROM a CROSS JOIN b ON a.id = b.id """) ``` - JOIN should parse as part of FROM, not after WHERE ```nim doAssertRaises(SqlParseError): discard parseSql(""" SELECT id FROM a WHERE a.id IS NOT NULL INNER JOIN b ON a.id = b.id """) ``` - LEFT JOIN should parse ```nim doAssert $parseSql(""" SELECT id FROM a LEFT JOIN b ON a.id = b.id """) == "select id from a left join b on a.id = b.id;" ``` - NATURAL JOIN should parse ```nim doAssert $parseSql(""" SELECT id FROM a NATURAL JOIN b """) == "select id from a natural join b;" ``` - USING should parse ```nim doAssert $parseSql(""" SELECT id FROM a JOIN b USING (id) """) == "select id from a join b using (id );" ``` - Multiple JOINs should parse ```nim doAssert $parseSql(""" SELECT id FROM a JOIN b ON a.id = b.id LEFT JOIN c USING (id) """) == "select id from a join b on a.id = b.id left join c using (id );" ```
- Loading branch information
Showing
2 changed files
with
152 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters