This is an automated email from the ASF dual-hosted git repository.
jermy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
The following commit(s) were added to refs/heads/master by this push:
new 7274a5f67 fix possible extra comma before where statement (#1924)
7274a5f67 is described below
commit 7274a5f67d310b6284fd9a8e9da25aae90b616aa
Author: Jermy Li <[email protected]>
AuthorDate: Tue Jul 19 11:25:30 2022 +0800
fix possible extra comma before where statement (#1924)
* fix: possible extra comma before where statement
add ',' before the next key construct & just skip thr first key
fix #1923
Change-Id: I095311942c3633a5978930e35fecd9fd47b08796
---
.../baidu/hugegraph/backend/store/mysql/MysqlTable.java | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
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 69efd96bd..c9ab719c2 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 @@ public abstract class MysqlTable
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 @@ public abstract class MysqlTable
}
protected String buildUpdateIfPresentTemplate(MysqlBackendEntry.Row entry)
{
-
StringBuilder update = new StringBuilder();
update.append("UPDATE ").append(this.table());
update.append(" SET ");
@@ -294,17 +293,15 @@ public abstract class MysqlTable
List<HugeKeys> 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();