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

druid 解析sql,如果sql中含有JSON_TABLE函数,会导致解析出来的sql错误 #4916

Closed
ocean-wll opened this issue Sep 1, 2022 · 3 comments
Labels
Milestone

Comments

@ocean-wll
Copy link

druid版本:1.2.11
原始sql:SELECT people.*
FROM t1,
JSON_TABLE(json_col, '$.people[*]' COLUMNS (
name VARCHAR(40) PATH '$.name',
address VARCHAR(100) PATH '$.address')
) people;
问题代码:com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlJSONTableExpr 的 toString()

image

问题描述:想通过druid解析sql代码实例如下:
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); final List<SQLStatement> sqlStatements = parser.parseStatementList();

发现当sql中含有 JSON_TABLE 会导致解析后的sql缺少一个逗号,执行时直接抛异常。

@ocean-wll
Copy link
Author

怀疑问题出现在 com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor#visit(com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlJSONTableExpr)
image

@ocean-wll
Copy link
Author

修改代码以后输出正确
image

@wenshao wenshao added this to the 1.2.12 milestone Sep 4, 2022
@wenshao wenshao added the Bug label Sep 4, 2022
@wenshao
Copy link
Member

wenshao commented Sep 10, 2022

https://github.com/alibaba/druid/releases/tag/1.2.12
druid-1.2.12版本已发布,请帮忙用新版本验证

@wenshao wenshao closed this as completed Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants