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

[BUG] druid Create table SQL解析问题,Comment属性解析错误 将COLLATE属性解析为表达式 #6214

Open
zhanghuancode opened this issue Nov 5, 2024 · 0 comments

Comments

@zhanghuancode
Copy link

Database Type

MySQL

Database Version

MySQL 8.0

Druid Version

1.2.23

JDK Version

JDK 1.8

Error SQL

CREATE TABLE table_name
(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
inserttime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '插入时间',
updatetime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
isactive TINYINT(1) NOT NULL DEFAULT '1' COMMENT '逻辑删除标识',
PRIMARY KEY (id) USING BTREE
)
COMMENT ='table_comment'
COLLATE = 'utf8mb4_unicode_ci'
ENGINE = InnoDB;

Testcase Code

        List<SQLStatement> smList = SQLUtils.parseStatements(sql, 'mysql');
        SQLCreateTableStatement createTableStatement = smList.get(0);
        if (null == createTableStatement.getComment()) {
            log.error("表备注不能为空!");
            return ;
        }
        object.setNew_table_remarks(createTableStatement.getComment().toString());

Stacktrace Info

No response

Error Info

comment JsonString 类型SQLBinaryOpExpr

{
"attributes": {},
"attributesDirect": {
"$ref": "$.attributes"
},
"bothName": false,
"children": [
{
"attributes": {},
"attributesDirect": {
"$ref": "$.children[0].attributes"
},
"children": [],
"parent": {
"$ref": "$"
},
"parenthesized": false,
"sourceColumn": 0,
"sourceLine": 0,
"text": "table_comment",
"value": "table_comment"
},
{
"attributes": {},
"attributesDirect": {
"$ref": "$.children[1].attributes"
},
"children": [],
"lowerName": "utf8mb4_unicode_ci",
"name": "utf8mb4_unicode_ci",
"parent": {
"$ref": "$"
},
"parenthesized": false,
"simpleName": "utf8mb4_unicode_ci",
"sourceColumn": 0,
"sourceLine": 0
}
],
"dbType": "mysql",
"left": {
"$ref": "$.children[0]"
},
"leftFunctionAndRightLiteral": false,
"leftLiteralAndRightName": true,
"leftNameAndRightLiteral": false,
"nameAndLiteral": true,
"operator": "COLLATE",
"parenthesized": false,
"right": {
"$ref": "$.children[1]"
},
"sourceColumn": 0,
"sourceLine": 0
}

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

1 participant