Skip to content

Postgres: DROP c reformatted to DROP COLUMN c #1859

Closed
@agis

Description

@agis

With v0.56.0 using the Postgres dialect, ALTER TABLE x DROP c is reformatted to ALTER TABLE x DROP COLUMN c.

use sqlparser::dialect::PostgreSqlDialect;
use sqlparser::parser::Parser;

fn main() {
    let sql = "ALTER TABLE foo DROP bar";
    let stmts = Parser::parse_sql(&PostgreSqlDialect {}, sql).unwrap();

    println!("{}", stmts[0]) // => "ALTER TABLE foo DROP COLUMN bar"
}

In Postgres, the COLUMN keyword is optional as per the official Postgres docs. According to sqlparser's README I would expect that the COLUMN keyword is not added:

This crate allows users to recover the original SQL text (with comments removed, normalized whitespace and keyword capitalization), which is useful for tools that analyze and manipulate SQL.

Would you classify this as a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions