We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
4.0.0
MySQL
SELECT * FROM tb where ;
import { FlinkSQL } from "dt-sql-parser"; const flink = new FlinkSQL(); const sql = "SELECT * FROM tb where ;"; console.log(sql.length);// 27 const pos = { lineNumber: 1, column: 25 }; // tb 的后面 const entities = flink.getAllEntities(sql, pos); console.log(entities);// [0].belongStmt.isContainCaret 为false
sql语句长27个字符,当光标在第25个字符,也就是where后面2个空格的位置 期望打印的isContainCaret为true
No response
The text was updated successfully, but these errors were encountered:
想使用光标位置获取当语句内出现的表名,去做字段推荐。 经过测试发现除了where其他的比如order by这样的后面都无法判断在同一个语句内
Sorry, something went wrong.
猜测是因为在语法规则src/grammar/mysql/MySqlParser.g4里,whereClause必须带后面的表达式才能被作为一个token。单纯的where不被作为一个token:
src/grammar/mysql/MySqlParser.g4
所以实际上解析时上下文丢弃了where之后的内容,又因为光标位也在where之后,所以根据iisContainCaret的逻辑:
不满足结束tokenIndex大于光标位置,所以就返回false了。
这个可以暂时通过在where后面添加一个占位符来workaround,其他有类似情况的语句同。
SELECT * FROM tb WHERE CARET;
彻底解决估计还得看官方如何处理这块的语法。
No branches or pull requests
Version
4.0.0
Which SQL?
MySQL
SQL content
JavaScript/TypeScript code
What happened?
sql语句长27个字符,当光标在第25个字符,也就是where后面2个空格的位置
期望打印的isContainCaret为true
Relevant log output
No response
The text was updated successfully, but these errors were encountered: