Skip to content

Table comment is always parsed as CommentDef::WithoutEq #1452

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
yshrsmz opened this issue Oct 2, 2024 · 0 comments · Fixed by #1453
Closed

Table comment is always parsed as CommentDef::WithoutEq #1452

yshrsmz opened this issue Oct 2, 2024 · 0 comments · Fixed by #1453

Comments

@yshrsmz
Copy link

yshrsmz commented Oct 2, 2024

Say I have the following table:

CREATE TABLE users (
  user_id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '口座内部ID',
  user_name VARCHAR(255) NOT NULL,
  PRIMARY KEY (user_id),
) COMMENT = 'users of the service';

And I parse and re-build it with sqlparser like this:

use sqlparser::{
    dialect,
    parser::Parser,
};

pub fn test() {
    let dialect = dialect::GenericDialect {};
    let parsed = Parser::parse_sql(&dialect, r#"
        CREATE TABLE users (
            user_id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '口座内部ID',
            user_name VARCHAR(255) NOT NULL,
            PRIMARY KEY (user_id)
        ) COMMENT = 'users of the service';
    "#);

    let binding = parsed.unwrap();
    let stmt = binding.first().unwrap();

    println!("{}", stmt.to_string());
}

then I got the following result:

CREATE TABLE users (user_id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '口座内部ID', user_name VARCHAR(255) NOT NULL, PRIMARY KEY (user_id)) COMMENT 'users of the service'

It looks like a table comment is always treated as CommentDef::WithoutEq here.

https://github.com/apache/datafusion-sqlparser-rs/blob/main/src/parser/mod.rs#L5877

git-hulk added a commit to git-hulk/sqlparser-rs that referenced this issue Oct 2, 2024
yshrsmz added a commit to yshrsmz/sqlstitch that referenced this issue Nov 30, 2024
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 a pull request may close this issue.

1 participant