Skip to content

Commit

Permalink
[ISSUE #8312]Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Gamer-01 committed Oct 24, 2022
1 parent 8c09bb1 commit 13aec62
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,8 @@ public ConfigInfo findConfigInfo(long id) {
public ConfigInfoWrapper findConfigInfo(final String dataId, final String group, final String tenant) {
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
ConfigInfoMapper configInfoMapper = (ConfigInfoMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO).get();
final String sql = configInfoMapper.select(Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content"),
Collections.singletonList("id"));
final String sql = configInfoMapper.select(Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "type", "encrypted_data_key"),
Arrays.asList("data_id", "group_id", "tenant_id"));
final Object[] args = new Object[] {dataId, group, tenantTmp};
return databaseOperate.queryOne(sql, args, CONFIG_INFO_WRAPPER_ROW_MAPPER);

Expand Down Expand Up @@ -1273,7 +1273,7 @@ public int aggrConfigInfoCount(String dataId, String group, String tenant, List<
}
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
ConfigInfoAggrMapper configInfoAggrMapper = (ConfigInfoAggrMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO_AGGR).get();
String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds, isIn);
String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds.size(), isIn);

List<Object> objectList = com.alibaba.nacos.common.utils.CollectionUtils.list(dataId, group, tenantTmp);
objectList.addAll(datumIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ public int aggrConfigInfoCount(String dataId, String group, String tenant, List<
}
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
ConfigInfoAggrMapper configInfoAggrMapper = (ConfigInfoAggrMapper) mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO_AGGR).get();
String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds, isIn);
String sql = configInfoAggrMapper.aggrConfigInfoCount(datumIds.size(), isIn);
List<Object> objectList = com.alibaba.nacos.common.utils.CollectionUtils.list(dataId, group, tenantTmp);
objectList.addAll(datumIds);
Integer result = jt.queryForObject(sql, Integer.class, objectList.toArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public String batchRemoveAggr(List<String> datumList) {
datumString.append('\'').append(datum).append("',");
}
datumString.deleteCharAt(datumString.length() - 1);
return "DELETE FROM config_info_aggr WHERE data_id=? AND group_id=? AND tenant_id=? AND datum_id IN ("
return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN ("
+ datumString.toString() + ")";
}

@Override
public String aggrConfigInfoCount(List<String> datumIds, boolean isIn) {
public String aggrConfigInfoCount(int size, boolean isIn) {
StringBuilder sql = new StringBuilder(
" SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id");
if (isIn) {
sql.append(" IN (");
} else {
sql.append(" NOT IN (");
}
for (int i = 0, size = datumIds.size(); i < size; i++) {
for (int i = 0; i < size; i++) {
if (i > 0) {
sql.append(", ");
}
Expand All @@ -69,8 +69,8 @@ public String aggrConfigInfoCount() {

@Override
public String findConfigInfoAggr() {
return "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id=? AND "
+ "group_id=? AND tenant_id=? ORDER BY datum_id";
return "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id = ? AND "
+ "group_id = ? AND tenant_id = ? ORDER BY datum_id";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ConfigInfoBetaMapperByDerby extends AbstractMapper implements Confi

@Override
public String updateConfigInfo4BetaCas() {
return "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=? "
+ "WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')";
return "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ConfigInfoTagMapperByDerby extends AbstractMapper implements Config

@Override
public String updateConfigInfo4TagCas() {
return "UPDATE config_info_tag SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=? "
+ "WHERE data_id=? AND group_id=? AND tenant_id=? AND tag_id=? AND (md5=? OR md5 IS NULL OR md5='')";
return "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ public String batchRemoveAggr(List<String> datumList) {
for (String datum : datumList) {
datumString.append('\'').append(datum).append("',");
}
datumString.deleteCharAt(datumString.length() - 1);
return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN ("
+ datumString.toString() + ")";
}

@Override
public String aggrConfigInfoCount(List<String> datumIds, boolean isIn) {
public String aggrConfigInfoCount(int size, boolean isIn) {
StringBuilder sql = new StringBuilder(
" SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id");
if (isIn) {
sql.append(" IN (");
} else {
sql.append(" NOT IN (");
}
for (int i = 0, size = datumIds.size(); i < size; i++) {
for (int i = 0; i < size; i++) {
if (i > 0) {
sql.append(", ");
}
Expand All @@ -69,7 +70,7 @@ public String aggrConfigInfoCount() {
@Override
public String findConfigInfoAggr() {
return "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM "
+ "config_info_aggr WHERE data_id= ? AND group_id= ? AND tenant_id= ? ORDER BY datum_id";
+ "config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY datum_id";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ConfigInfoBetaMapperByMySql extends AbstractMapper implements Confi

@Override
public String updateConfigInfo4BetaCas() {
return "UPDATE config_info_beta SET content= ?, md5= ?, beta_ips= ?, src_ip= ?,src_user= ?,gmt_modified= ?,app_name= ? "
+ " WHERE data_id= ? AND group_id= ? AND tenant_id= ? AND (md5= ? or md5 is null or md5='')";
return "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? or md5 is null or md5 = '')";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ConfigInfoTagMapperByMySql extends AbstractMapper implements Config

@Override
public String updateConfigInfo4TagCas() {
return "UPDATE config_info_tag SET content= ?, md5 = ?, src_ip= ?,src_user= ?,gmt_modified= ?,app_name= ? WHERE "
+ "data_id= ? AND group_id= ? AND tenant_id= ? AND tag_id= ? AND (md5= ? or md5 is null or md5='')";
return "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public String update(List<String> columns, List<String> where) {
public String delete(List<String> params) {
StringBuilder sql = new StringBuilder();
String method = "DELETE ";
sql.append(method).append(" FROM ").append(getTableName()).append(" ");
sql.append(method).append(" FROM ").append(getTableName()).append(" ").append("WHERE ");
for (int i = 0; i < params.size(); i++) {
sql.append(params.get(i)).append(" ");
sql.append(params.get(i)).append(" ").append("=").append(" ? ");
if (i != params.size() - 1) {
sql.append("AND ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public interface ConfigInfoAggrMapper extends Mapper {
* The default sql:
* SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ?
*
* @param datumIds datum id list
* @param isIn search condition
* @param size datum id list size
* @param isIn search condition
* @return The sql of getting count of aggregation config info.
*/
String aggrConfigInfoCount(List<String> datumIds, boolean isIn);
String aggrConfigInfoCount(int size, boolean isIn);

/**
* Get count of aggregation config info.
Expand Down

0 comments on commit 13aec62

Please sign in to comment.