修复解析器for update错误.
https://github.com/baomidou/mybatis-plus/issues/2229 https://github.com/baomidou/mybatis-plus/issues/2364
This commit is contained in:
parent
723514f4cc
commit
2702ad909f
@ -89,11 +89,9 @@ public final class TableNameParser {
|
|||||||
if (isFromToken(currentToken)) {
|
if (isFromToken(currentToken)) {
|
||||||
processFromToken(tokens, index);
|
processFromToken(tokens, index);
|
||||||
} else if (shouldProcess(currentToken)) {
|
} else if (shouldProcess(currentToken)) {
|
||||||
String nextToken = tokens[index++];
|
|
||||||
considerInclusion(nextToken);
|
|
||||||
|
|
||||||
if (moreTokens(tokens, index)) {
|
if (moreTokens(tokens, index)) {
|
||||||
nextToken = tokens[index++];
|
String nextToken = tokens[index++];
|
||||||
|
considerInclusion(nextToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,6 +476,12 @@ public class TableNameParserTest {
|
|||||||
String sql = "select * -- I like stars \n from foo f -- I like foo \n join bar b -- I also like bar \n on f.id = b.id -- comment ending with update";
|
String sql = "select * -- I like stars \n from foo f -- I like foo \n join bar b -- I also like bar \n on f.id = b.id -- comment ending with update";
|
||||||
assertThat(new TableNameParser(sql).tables()).isEqualTo(asSet("foo","bar"));
|
assertThat(new TableNameParser(sql).tables()).isEqualTo(asSet("foo","bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSelectForUpdate() {
|
||||||
|
//TODO 暂时解决不能使用的问题,当碰到for update nowait这样的,后面的nowait会被当做成表但也不是很影响苗老板的动态表过滤.
|
||||||
|
assertThat(new TableNameParser("select * from mp where id = 1 for update").tables()).isEqualTo(asSet("mp"));
|
||||||
|
}
|
||||||
|
|
||||||
private static Collection<String> asSet(String... a) {
|
private static Collection<String> asSet(String... a) {
|
||||||
Set<String> result = new HashSet<String>();
|
Set<String> result = new HashSet<String>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user