Skip to content

Commit

Permalink
fix possible extra comma before where statement (#1924)
Browse files Browse the repository at this point in the history
* fix: possible extra comma before where statement

add ',' before the next key construct & just skip thr first key

fix #1923
Change-Id: I095311942c3633a5978930e35fecd9fd47b08796
  • Loading branch information
javeme authored Jul 19, 2022
1 parent 2f11ea5 commit 7274a5f
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ");
}
}
Expand Down Expand Up @@ -286,25 +286,22 @@ protected List<Object> buildColumnsParams(MysqlBackendEntry.Row entry,
}

protected String buildUpdateIfPresentTemplate(MysqlBackendEntry.Row entry) {

StringBuilder update = new StringBuilder();
update.append("UPDATE ").append(this.table());
update.append(" SET ");

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();
Expand Down

0 comments on commit 7274a5f

Please sign in to comment.