Skip to content

create drop schema conditionally #276

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 2 commits into from
Oct 2, 2020

Conversation

alex-dukhno
Copy link
Contributor

added CREATE SCHEMA IF NOT EXISTS ... for PostgreSQL
added test for DROP SCHEMA IF EXISTS ... as it was supported but no test for the case

@coveralls
Copy link

coveralls commented Oct 1, 2020

Pull Request Test Coverage Report for Build 283916036

  • 22 of 26 (84.62%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 91.83%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 3 4 75.0%
src/ast/mod.rs 4 7 57.14%
Totals Coverage Status
Change from base Build 279659934: -0.04%
Covered Lines: 4687
Relevant Lines: 5104

💛 - 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! See my two comments below.

This continues from #173 and I'll copy the spec links from that PR: SQL:2016 and Posgres. The IF NOT EXISTS is a Postgres-specific clause.

src/ast/mod.rs Outdated
if_not_exists,
} => write!(
f,
"CREATE SCHEMA{if_not_exists}{name}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Using "CREATE SCHEMA {if_not_exists}{name}" and an empty string for if_not_exists when it needs to be omitted both is consistent with other implementations, and results in more compact code.

#[test]
fn parse_create_schema_if_not_exists() {
let sql = "CREATE SCHEMA IF NOT EXISTS schema_name";
let ast = pg().verified_stmt(sql);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please default to pg_and_generic() unless testing a construct that can't be parsed by the generic parser. The idea of the generic parser is to be able to parse as much SQL code as possible.

@nickolay nickolay merged commit 1ac2083 into apache:main Oct 2, 2020
@alex-dukhno alex-dukhno deleted the create-drop-schema-conditionally branch October 2, 2020 14:40
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