Skip to content
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

feat: Parse special keywords as functions (current_user, user, etc) #561

Merged
merged 2 commits into from Aug 11, 2022

Conversation

ovr
Copy link
Contributor

@ovr ovr commented Aug 9, 2022

Hello!

Note: current_catalog, current_schema, current_user, session_user, and user have special syntactic status in SQL: they must be called without trailing parentheses. (In PostgreSQL, parentheses can optionally be used with current_schema, but not with the others.)

https://www.postgresql.org/docs/9.1/functions-info.html

Thanks

@coveralls
Copy link

coveralls commented Aug 9, 2022

Pull Request Test Coverage Report for Build 2839618346

  • 39 of 50 (78.0%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 89.945%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/mod.rs 7 10 70.0%
src/parser.rs 5 13 38.46%
Files with Coverage Reduction New Missed Lines %
src/parser.rs 1 83.21%
Totals Coverage Status
Change from base Build 2839268478: -0.04%
Covered Lines: 9240
Relevant Lines: 10273

💛 - Coveralls

@alamb alamb changed the title feat: Parse special keywors as functions (current_user, user, etc) feat: Parse special keywords as functions (current_user, user, etc) Aug 11, 2022
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @ovr -- looks good to me except for a question about the special field

@@ -2243,20 +2243,27 @@ pub struct Function {
pub over: Option<WindowSpec>,
// aggregate functions may specify eg `COUNT(DISTINCT x)`
pub distinct: bool,
pub special: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why a special field is needed ? Wouldn't it be enough to match on the name?

If we do need a special field, can you please add a /// comment explaining what it means and what it is used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this field to skip formating (arguments).

image

Right now, Dialect is not available in formating, because we use fmt::Display for implementing to_string() method.

@alamb
Copy link
Collaborator

alamb commented Aug 11, 2022

Marking this as a draft to show it is waiting some changes so I can easily filter out which PRs need review. Please mark it as "ready for review" when it is next ready.

@alamb alamb marked this pull request as draft August 11, 2022 10:48
@ovr ovr force-pushed the special-keyword-functions-pr branch from 8b700ff to a6a3340 Compare August 11, 2022 12:00
@ovr ovr marked this pull request as ready for review August 11, 2022 12:05
@alamb
Copy link
Collaborator

alamb commented Aug 11, 2022

Thanks @ovr

@alamb alamb merged commit 54a29e8 into sqlparser-rs:main Aug 11, 2022
@ovr ovr deleted the special-keyword-functions-pr branch August 11, 2022 13:01
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.

None yet

3 participants