diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java index 69efd96bda..c9ab719c21 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java @@ -235,18 +235,18 @@ protected String buildInsertKeys(StringBuilder insert, insert.append(" ("); int i = 0; - int n = entry.columns().size(); + int size = entry.columns().size(); for (HugeKeys key : entry.columns().keySet()) { insert.append(formatKey(key)); - if (++i != n) { + if (++i != size) { insert.append(", "); } } insert.append(") VALUES ("); // Fill with '?' as a placeholder - for (i = 0; i < n; i++) { + for (i = 0; i < size; i++) { insert.append("?"); - if (i != n - 1) { + if (i != size - 1) { insert.append(", "); } } @@ -286,7 +286,6 @@ protected List buildColumnsParams(MysqlBackendEntry.Row entry, } protected String buildUpdateIfPresentTemplate(MysqlBackendEntry.Row entry) { - StringBuilder update = new StringBuilder(); update.append("UPDATE ").append(this.table()); update.append(" SET "); @@ -294,17 +293,15 @@ protected String buildUpdateIfPresentTemplate(MysqlBackendEntry.Row entry) { List idNames = this.idColumnName(); int i = 0; - int size = entry.columns().size(); for (HugeKeys key : entry.columns().keySet()) { if (idNames.contains(key)) { - size--; continue; } - update.append(formatKey(key)); - update.append("=?"); - if (++i != size) { + if (i++ > 0) { update.append(", "); } + update.append(formatKey(key)); + update.append("=?"); } WhereBuilder where = this.newWhereBuilder();