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

Add support for AUTHORIZATION clause in CREATE SCHEMA statements #646

Merged
merged 1 commit into from Oct 3, 2022
Merged

Add support for AUTHORIZATION clause in CREATE SCHEMA statements #646

merged 1 commit into from Oct 3, 2022

Conversation

AugustoFKL
Copy link
Contributor

Adding support for AUTHORIZATION on CREATE SCHEMA (1, 2) using a new enum structure. I used that structure because it makes it easier to validate and handle than Options. The other possible approach was:

pub enum Statement {
//...
    CreateSchema {
        schema_name: Option<ObjectName>,
        authorization_name: Option<Ident>
        if_not_exists: bool,
    },
//...
}

But it has a few problems:

  1. It's harder to parse
  2. We can't have both false, but that structure would allow that
  3. It's harder for the caller to know what's happening.

[1] : https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#schema-definition
[2] : https://www.postgresql.org/docs/current/sql-createschema.html
Resolves: #645

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3166818910

  • 44 of 44 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 85.627%

Totals Coverage Status
Change from base Build 3166221109: 0.05%
Covered Lines: 10229
Relevant Lines: 11946

💛 - Coveralls

@AugustoFKL
Copy link
Contributor Author

@alamb ready for review :D

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.

Looks really nice -- thank you @AugustoFKL

@alamb alamb changed the title 645 New schema name structure Add support for AUTHORIZATION clause in CREATE SCHEMA Oct 3, 2022
@alamb alamb changed the title Add support for AUTHORIZATION clause in CREATE SCHEMA Add support for AUTHORIZATION clause in CREATE SCHEMA statements Oct 3, 2022
@alamb alamb merged commit 1ced0f6 into sqlparser-rs:main Oct 3, 2022
@AugustoFKL AugustoFKL deleted the 645_create-schema-with-authorization branch October 4, 2022 18:11
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.

Create schema name allowing AUTHORIZATION
3 participants