-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
[SQLParser]列名外的引号在解析后丢失。 #682
Comments
补充一下,MySQL的转义符就没这个问题——
希望能一视同仁。 |
SQL Server使用sql关键字做字段名时,可以加上[] |
To yakolee: 是的,你的建议很好的解决了我的问题。因为Oracle、MYSQL等数据库的分页改写规则非常简单,无需用到AST,唯有SQLServer的分页改写复杂一些。 不过我重新测试了一下相关功能以后,建议你们还是在 SQLExprParser.java : 653的地方,即方法
中,将Token.IDENTIFIER和Token.LITERAL_CHARS两种Token分开处理。
即可解决我提出的问题。为什么这样说呢?你们不妨运行一下
会发现 t."desc"中的引号丢掉了,而"top"的引号缺没有丢掉。因为在SQLExprParser.java : 554行是这样写的
这就是说,当没有表名限定符时返回SQLIdentifierExpr时保留了引号,当加上表名限定符后,返回的SQLPropertyExpr中丢失了引号。这造成了同一个框架内的行为不一致。 |
接上贴。因为同样是列名,有时是SQLIdentifierExpr,有时是SQLPropertyExpr中的name属性。这样的AST访问较为困难,让Visitor的访问行为变得难以编写,不利于扩展。 |
使用Druid Parser编写了一个SQLServer2005的LimitHandler,用于将SQL语句改写为分页后的SQL语句。当数据库列使用SQLServer保留字以后,拟使用引号来修饰在列名。但发现解析后引号丢失。测试案例如下——
The text was updated successfully, but these errors were encountered: