mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed and close #I6X4U8
This commit is contained in:
parent
9265fa7755
commit
3af6c82c67
@ -54,6 +54,10 @@ public class Brackets extends QueryCondition {
|
||||
return checkEffective() ? WrapperUtil.getValues(childCondition) : null;
|
||||
}
|
||||
|
||||
public QueryCondition getChildCondition(){
|
||||
return childCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSql(List<QueryTable> queryTables, IDialect dialect) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
|
||||
@ -38,22 +38,34 @@ class WrapperUtil {
|
||||
List<QueryWrapper> list = null;
|
||||
while (condition != null) {
|
||||
if (condition.checkEffective()) {
|
||||
Object value = condition.getValue();
|
||||
if (value instanceof QueryWrapper) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
if (condition instanceof Brackets) {
|
||||
List<QueryWrapper> childQueryWrapper = getChildSelect(((Brackets) condition).getChildCondition());
|
||||
if (!childQueryWrapper.isEmpty()) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.addAll(childQueryWrapper);
|
||||
}
|
||||
list.add((QueryWrapper) value);
|
||||
list.addAll(((QueryWrapper) value).getChildSelect());
|
||||
} else if (value != null && value.getClass().isArray()) {
|
||||
for (int i = 0; i < Array.getLength(value); i++) {
|
||||
Object arrayValue = Array.get(value, i);
|
||||
if (arrayValue instanceof QueryWrapper) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
// not Brackets
|
||||
else {
|
||||
Object value = condition.getValue();
|
||||
if (value instanceof QueryWrapper) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add((QueryWrapper) value);
|
||||
list.addAll(((QueryWrapper) value).getChildSelect());
|
||||
} else if (value != null && value.getClass().isArray()) {
|
||||
for (int i = 0; i < Array.getLength(value); i++) {
|
||||
Object arrayValue = Array.get(value, i);
|
||||
if (arrayValue instanceof QueryWrapper) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add((QueryWrapper) arrayValue);
|
||||
list.addAll(((QueryWrapper) arrayValue).getChildSelect());
|
||||
}
|
||||
list.add((QueryWrapper) arrayValue);
|
||||
list.addAll(((QueryWrapper) arrayValue).getChildSelect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,6 +64,19 @@ public class EntityTestStarter {
|
||||
// Page<Account> paginate = accountMapper.paginate(1,10,queryWrapper);
|
||||
// System.out.println(paginate);
|
||||
|
||||
|
||||
|
||||
// QueryWrapper query = QueryWrapper.create()
|
||||
// .where(ACCOUNT.ID.in(
|
||||
// select(ACCOUNT.ID).from(ACCOUNT)
|
||||
// .where(ACCOUNT.ID.eq(1))
|
||||
// ).and("1 = 1")
|
||||
// );
|
||||
//
|
||||
// List<Account> accounts = accountMapper.selectListByQuery(query);
|
||||
// System.out.println(accounts);
|
||||
|
||||
|
||||
// List<Account> accounts = new ArrayList<>();
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// Account account = new Account();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user