Skip to content

Don't silently accept naked OUTER JOINS #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2019
Merged

Don't silently accept naked OUTER JOINS #118

merged 1 commit into from
Jun 18, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 17, 2019

SELECT * FROM a OUTER JOIN b was previously being parsed as an inner
join where table a was aliased to OUTER. This is extremely
surprising, as the user likely intended to say FULL OUTER JOIN. Since
the SQL specification lists OUTER as a keyword, we are well within our
rights to return an error here.

@nickolay I realize this will conflict with #116—definitely feel free to merge that one first!

@benesch benesch requested a review from nickolay June 17, 2019 21:14
@coveralls
Copy link

coveralls commented Jun 17, 2019

Pull Request Test Coverage Report for Build 357

  • 4 of 5 (80.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 92.221%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tests/sqlparser_common.rs 3 4 75.0%
Totals Coverage Status
Change from base Build 355: -0.01%
Covered Lines: 4315
Relevant Lines: 4679

💛 - Coveralls

Copy link
Contributor

@nickolay nickolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I didn't include OUTER initially as I was unsure about Oracle, which lists it as a non-reserved keyword, and it wasn't required for parsing. Since then I learned the modern versions of Oracle support OUTER APPLY (borrowed from MSSQL), so I was going to add this anyway.

Going forward I expect this list to be dialect-specific, but forbidding OUTER makes sense for the time being.

(The SQL specification lists too many keywords as reserved, so keyword being in its reserved list is not a good reason to forbid it from being used as an identifier. Unless you're aiming for conformance, in which case it should arguably be handled elsewhere.)

@nickolay I realize this will conflict with #116—definitely feel free to merge that one first!

Yeah, I've merged my PR before seeing this one...

`SELECT * FROM a OUTER JOIN b` was previously being parsed as an inner
join where table `a` was aliased to `OUTER`. This is extremely
surprising, as the user likely intended to say FULL OUTER JOIN. Since
the SQL specification lists OUTER as a keyword, we are well within our
rights to return an error here.
@benesch
Copy link
Contributor Author

benesch commented Jun 18, 2019

Awesome, thanks for the review!

@benesch benesch merged commit e6b2633 into master Jun 18, 2019
@benesch benesch deleted the outer-join branch June 18, 2019 17:15
@@ -422,7 +422,12 @@ pub const RESERVED_FOR_TABLE_ALIAS: &[&str] = &[
// Reserved as both a table and a column alias:
WITH, SELECT, WHERE, GROUP, HAVING, ORDER, LIMIT, OFFSET, FETCH, UNION, EXCEPT, INTERSECT,
// Reserved only as a table alias in the `FROM`/`JOIN` clauses:
ON, JOIN, INNER, CROSS, FULL, LEFT, RIGHT, NATURAL, USING,
ON, JOIN, INNER, CROSS, FULL, LEFT, RIGHT, NATURAL, USING, LIMIT, OFFSET, FETCH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, LIMIT, OFFSET, FETCH, here is the result of a rebase going bad..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this in a moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh! Sorry. I distinctly remember intentionally resolving this conflict in favor of "adding" the new keywords without realizing they were in fact duplicates.

nickolay added a commit to nickolay/sqlparser-rs that referenced this pull request Jun 18, 2019
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.

3 participants