You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`id`, `msg_id`, `reconciliation_diff_id`, `bank`, `fund_type`, `batch_no`, `settle_serial`,
`bank_repay_status`, `order_no`, `stage`, `standing_book_id`, `recon_date`, `settlement_date`,
`settlement_type`, `self_amount`, `bank_amount`, `diff_amount`, `compensatory`, `settlement_label`, `result`,
`process_status`, `edition`, `extra1`, `extra2`, `extra3`, `created_at`, `updated_at`
from `reconciliation_diff_queue_msg`
force index(idx_process_status)
where `process_status` = ?
and `id` > ?
and settlement_type not in (0,7)
and `fund_type` = ?
and substr(order_no, -4, 4) between ? and ?
order by `id` ASC
limit ?
Testcase Code
@TestpublicvoidtestReplace2() {
Stringsql = "select\n" +
" \n" +
" \n" +
" `id`, `msg_id`, `reconciliation_diff_id`, `bank`, `fund_type`, `batch_no`, `settle_serial`,\n" +
" `bank_repay_status`, `order_no`, `stage`, `standing_book_id`, `recon_date`, `settlement_date`,\n" +
" `settlement_type`, `self_amount`, `bank_amount`, `diff_amount`, `compensatory`, `settlement_label`, `result`,\n" +
" `process_status`, `edition`, `extra1`, `extra2`, `extra3`, `created_at`, `updated_at`\n" +
" \n" +
" from `reconciliation_diff_queue_msg`\n" +
" force index(idx_process_status)\n" +
" where `process_status` = ?\n" +
" and `id` > ?\n" +
" \n" +
" \n" +
" and settlement_type not in (0,7)\n" +
" \n" +
" \n" +
" and `fund_type` = ?\n" +
" and substr(order_no, -4, 4) between ? and ?\n" +
" order by `id` ASC\n" +
" limit ?";
//这里指定tidb 就解析失败, 指定mysql就可以//看起来mysql 语法集兼容性更大一些,是不是不管什么数据库类型, 都可以无脑用mysqlList<SQLStatement> sqlStatements = com.alibaba.druid.sql.SQLUtils.parseStatements(sql, "tidb");
System.out.println(sqlStatements);
Stacktrace Info
No response
Error Info
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'orce index(idx_process_status)
', expect INDEX, actual INDEX pos 511, line 10, column 15, token INDEX
at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:284)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:433)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:72)
at com.alibaba.druid.sql.SQLUtils.parseStatements(SQLUtils.java:464)
at cn.caijiajia.dal.jdbc.core.datasource.collect.utils.SQLUtilsTest.testReplace2(SQLUtilsTest.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
The text was updated successfully, but these errors were encountered:
SQLUtils.parseStatements(sql, "tidb")
使用Druid 解析, 测下来目前看起来mysql 语法集兼容性更大一些 ! 是不是不管什么数据库类型, 都可以无脑用mysql类型?
比如下面这个sql , 目标库是tidb ,但是用tidb 的类型去解析的话解析失败, 用mysql 类型解析则能正常解析
Druid Version
1.2.11
JDK Version
jdk8
Error SQL
select
Testcase Code
Stacktrace Info
No response
Error Info
The text was updated successfully, but these errors were encountered: