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

support DROP FUNCTION syntax #752

Merged
merged 6 commits into from Dec 28, 2022
Merged

Conversation

zidaye
Copy link
Contributor

@zidaye zidaye commented Dec 8, 2022

@coveralls
Copy link

coveralls commented Dec 8, 2022

Pull Request Test Coverage Report for Build 3764235521

  • 95 of 111 (85.59%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.008%) to 86.328%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 24 31 77.42%
src/ast/mod.rs 13 22 59.09%
Totals Coverage Status
Change from base Build 3720056662: -0.008%
Covered Lines: 12856
Relevant Lines: 14892

💛 - Coveralls

src/ast/mod.rs Outdated
if_exists: bool,
/// One or more function to drop
func_desc: Vec<DropFunctionDesc>,
cascade: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

@zidaye maybe an enum here would be better (or an option with a boolean inside).

Here you allow the state "cascade + restrict", which doesn't make sense at all.

Copy link
Contributor Author

@zidaye zidaye Dec 10, 2022

Choose a reason for hiding this comment

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

@AugustoFKL done.

@alamb alamb changed the title Add delete function method support DROP FUNCTION syntax Dec 13, 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 for the contribution @zidaye

I have some suggestions, but overall this PR is looking close

src/ast/mod.rs Outdated
/// One or more function to drop
func_desc: Vec<DropFunctionDesc>,
/// `CASCADE` or `RESTRICT`
option: Option<DropFunctionOption>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

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 will change it later, thanks for your suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DropFunction {
if_exists: bool,
/// One or more function to drop
func_desc: Vec<DropFunctionDesc>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about reusing the CreateFunctionArg structure used in CREATE FUNCTION

sqlparser-rs/src/ast/mod.rs

Lines 1410 to 1417 in d420001

CreateFunction {
or_replace: bool,
temporary: bool,
name: ObjectName,
args: Option<Vec<CreateFunctionArg>>,
return_type: Option<DataType>,
/// Optional parameters.
params: CreateFunctionBody,

?

I can also see the argument for using a separate struct. If we stay with a separate struct, I suggest we name if DropFunctionArg to mirror the CreateFunctionArg

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'll try to combine these structures later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about reusing the CreateFunctionArg structure used in CREATE FUNCTION

sqlparser-rs/src/ast/mod.rs

Lines 1410 to 1417 in d420001

CreateFunction {
or_replace: bool,
temporary: bool,
name: ObjectName,
args: Option<Vec<CreateFunctionArg>>,
return_type: Option<DataType>,
/// Optional parameters.
params: CreateFunctionBody,

?

I can also see the argument for using a separate struct. If we stay with a separate struct, I suggest we name if DropFunctionArg to mirror the CreateFunctionArg

sorry for my late reply。I've reconsidered your suggestion, and I think the structure might be acceptable. The DropFunctionDesc contains the function name and function parameters. The CreateFunctionArg only describes function parameters. Also, CreateFunctionArg has been reused and renamed OperateFunctionArg

@alamb alamb marked this pull request as draft December 14, 2022 10:47
@alamb
Copy link
Collaborator

alamb commented Dec 14, 2022

marking as draft -- please mark as ready for review when you have made the changes you plan. Thank you

@zidaye zidaye marked this pull request as ready for review December 20, 2022 07:14
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 @zidaye

@alamb alamb merged commit 2d801c9 into sqlparser-rs:main Dec 28, 2022
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.

Postgres: does not support DROP FUNCTION
4 participants