Skip to content

Commit

Permalink
fix(alibaba#12231): When inserting and updating configurations in the…
Browse files Browse the repository at this point in the history
… database, the time-related field values need to be set using the time obtained from the database's built-in time function.
  • Loading branch information
Bo-Qiu committed Jun 15, 2024
1 parent d1bb9e3 commit e9ff764
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public interface ConfigInfoBetaMapper extends Mapper {
* @return The result of updating beta configuration information.
*/
default MapperResult updateConfigInfo4BetaCas(MapperContext context) {
final String sql = "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? "
final String sql = "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,"
+ "src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 is null OR md5 = '')";

List<Object> paramList = new ArrayList<>();

paramList.add(context.getUpdateParameter(FieldConstant.CONTENT));
paramList.add(context.getUpdateParameter(FieldConstant.MD5));
paramList.add(context.getUpdateParameter(FieldConstant.BETA_IPS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public void testUpdateConfigInfo4BetaCas() {

String sql = mapperResult.getSql();
Assert.assertEquals(sql,
"UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? "
"UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,"
+ "src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 is null OR md5 = '')");
Assert.assertArrayEquals(mapperResult.getParamList().toArray(),
new Object[]{newContent, newMD5, betaIps, srcIp, srcUser, appNameTmp, dataId, group, tenantId,
Expand Down

0 comments on commit e9ff764

Please sign in to comment.