mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
Merge pull request #342 from 98Kming/main
fix https://github.com/mybatis-flex/mybatis-flex/issues/307
This commit is contained in:
commit
e04e36c8c6
@ -295,13 +295,29 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
|
|||||||
if (column == null || !checkEffective()) {
|
if (column == null || !checkEffective()) {
|
||||||
return nextContainsTable(tables);
|
return nextContainsTable(tables);
|
||||||
}
|
}
|
||||||
|
if (column instanceof FunctionQueryColumn) {
|
||||||
|
/*
|
||||||
|
* 连表分页查询的where中使用QueryMethods导致count查询优化错误
|
||||||
|
* fix https://github.com/mybatis-flex/mybatis-flex/issues/307
|
||||||
|
*/
|
||||||
|
List<QueryColumn> columns = ((FunctionQueryColumn)column).getColumns();
|
||||||
|
for (QueryColumn queryColumn : columns) {
|
||||||
|
if (containsTable(queryColumn, tables)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return containsTable(column, tables) || nextContainsTable(tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean containsTable(QueryColumn column, String... tables) {
|
||||||
for (String table : tables) {
|
for (String table : tables) {
|
||||||
String tableName = StringUtil.getTableNameWithAlias(table)[0];
|
String tableName = StringUtil.getTableNameWithAlias(table)[0];
|
||||||
if (column.table != null && tableName.equals(column.table.name)) {
|
if (column.table != null && tableName.equals(column.table.name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nextContainsTable(tables);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean nextContainsTable(String... tables) {
|
boolean nextContainsTable(String... tables) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user