Skip to content

Add support for union without brackets and with limit - #1132

Merged
wumpz merged 2 commits into
JSQLParser:masterfrom
tomershay:support_union_without_bracks_and_with_limit
Mar 14, 2021
Merged

wumpz merged 2 commits into
JSQLParser:masterfrom
tomershay:support_union_without_bracks_and_with_limit

Conversation

@tomershay

Copy link
Copy Markdown
Contributor

The parser misplaces the LIMIT clause when parsing a UNION query that doesn't include brackets.

The original query:
select col from tbl union distinct select col2 from tbl order by test limit 100;
The query after parsing (before the fix):
SELECT tbl.col FROM tbl UNION DISTINCT SELECT tbl.col2 FROM tbl LIMIT 100 ORDER BY test

Note that the LIMIT clause shows up before the ORDER BY clause, which is invalid.

After the fix, the query parses as the same as the original query.

Fixes #1018
Fixes #1116

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 88.481% when pulling e86b7ad on tomershay:support_union_without_bracks_and_with_limit into bcc683a on JSQLParser:master.

@wumpz
wumpz merged commit 56c2dfe into JSQLParser:master Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Union with order and limit LIMIT is misplaced when placed at the bottom of a UNION query

3 participants