mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
commit
eafe6d338f
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.mybatisflex.core.dialect;
|
||||
|
||||
import com.mybatisflex.core.query.QueryTable;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import com.mybatisflex.core.table.TableInfo;
|
||||
@ -64,6 +65,10 @@ public interface IDialect {
|
||||
|
||||
String buildSelectSql(QueryWrapper queryWrapper);
|
||||
|
||||
default String buildSelectSql(QueryWrapper queryWrapper, List<QueryTable> contextTables) {
|
||||
return buildSelectSql(queryWrapper);
|
||||
}
|
||||
|
||||
String buildNoSelectSql(QueryWrapper queryWrapper);
|
||||
|
||||
String buildDeleteSql(QueryWrapper queryWrapper);
|
||||
|
||||
@ -395,10 +395,16 @@ public class CommonsDialectImpl implements IDialect {
|
||||
////////////build query sql///////
|
||||
@Override
|
||||
public String buildSelectSql(QueryWrapper queryWrapper) {
|
||||
return buildSelectSql(queryWrapper, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildSelectSql(QueryWrapper queryWrapper, List<QueryTable> contextTables) {
|
||||
List<QueryTable> queryTables = CPI.getQueryTables(queryWrapper);
|
||||
|
||||
List<QueryTable> joinTables = CPI.getJoinTables(queryWrapper);
|
||||
List<QueryTable> allTables = CollectionUtil.merge(queryTables, joinTables);
|
||||
allTables = CollectionUtil.merge(allTables, contextTables);
|
||||
|
||||
List<QueryColumn> selectColumns = CPI.getSelectColumns(queryWrapper);
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ public class OperatorSelectCondition extends QueryCondition {
|
||||
|
||||
//检测是否生效
|
||||
if (checkEffective()) {
|
||||
String childSql = dialect.buildSelectSql(queryWrapper);
|
||||
String childSql = dialect.buildSelectSql(queryWrapper, queryTables);
|
||||
if (StringUtil.hasText(childSql)) {
|
||||
QueryCondition prevEffectiveCondition = getPrevEffectiveCondition();
|
||||
if (prevEffectiveCondition != null && this.connector != null) {
|
||||
|
||||
@ -400,7 +400,7 @@ public class AccountSqlTester {
|
||||
|
||||
Assert.assertEquals("SELECT * FROM `tb_account` " +
|
||||
"WHERE `id` >= 100 " +
|
||||
"AND EXISTS (SELECT 1 AS `temp_one` FROM `tb_article` AS `a` WHERE `id` >= 100)"
|
||||
"AND EXISTS (SELECT 1 AS `temp_one` FROM `tb_article` AS `a` WHERE `a`.`id` >= 100)"
|
||||
, query.toSQL());
|
||||
|
||||
System.out.println(query.toSQL());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user