Skip to content

alter table drop constraint throws an error. #342

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

Closed
tvallotton opened this issue Sep 2, 2021 · 2 comments
Closed

alter table drop constraint throws an error. #342

tvallotton opened this issue Sep 2, 2021 · 2 comments

Comments

@tvallotton
Copy link
Contributor

tvallotton commented Sep 2, 2021

Hi, the following test does not pass. I would expect this to work.

use sqlparser::*;

#[test]
fn func() {
    let stmt = "ALTER TABLE table_name DROP CONSTRAINT constr_name;";

    let x = parser::Parser::parse_sql(&dialect::GenericDialect {}, stmt);
    dbg!(x).unwrap();
}

(Also, DropConstraint { name: Ident } should probably also contain fields for cascade/restrict, and possibly if_exists )

@tvallotton
Copy link
Contributor Author

tvallotton commented Sep 2, 2021

Note that when constructing the value by hand and transforming it to a string, we get the expected result:

use sqlparser::ast::{AlterTableOperation, Ident, ObjectName, Statement};

#[test]
fn func() {
    let stmt = Statement::AlterTable {
        name: ObjectName(vec![Ident::new("table_name")]),
        operation: AlterTableOperation::DropConstraint {
            name: Ident::new("constraint_name"),
        },
    };
    println!("{}", stmt);
}
ALTER TABLE table_name DROP CONSTRAINT constraint_name

@alamb
Copy link
Contributor

alamb commented Feb 9, 2022

fixed in #396

@alamb alamb closed this as completed Feb 9, 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

No branches or pull requests

2 participants