Skip to content

Commit f375abc

Browse files
Andrew Farriesroboquat
authored andcommitted
Escape column name in UPDATE statement
1 parent 25900ec commit f375abc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

components/ee/db-sync/src/export.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class TableUpdate {
136136

137137
const pkValues = this.table.primaryKeys.map(c => escape(row[c], true));
138138
const updateValues = this.updateColumns.map(c => escape(row[c], true));
139-
const updates = this.updateColumns.map((c, i) => `${c}=${updateValues[i]}`).join(", ")
139+
const updates = this.updateColumns.map((c, i) => `${escapeWithBackticks(c)}=${updateValues[i]}`).join(", ")
140140
const updateConditions = this.getUpdateConditions(row);
141141

142142
let result = [`INSERT${forceInsert ? '' : ' IGNORE'} INTO ${this.table.name} (${(this.table.primaryKeys.concat(this.updateColumns)).map(escapeWithBackticks).join(", ")}) VALUES (${(pkValues.concat(updateValues)).join(", ")});`];
@@ -147,7 +147,7 @@ export class TableUpdate {
147147
}
148148

149149
protected getUpdateConditions(row: any): string {
150-
return this.table.primaryKeys.map(pk => `${pk}=${escape(row[pk])}`).concat([`${this.table.timeColumn}<=${escape(row[this.table.timeColumn])}`]).join(" AND ");
150+
return this.table.primaryKeys.map(pk => `${escapeWithBackticks(pk)}=${escape(row[pk])}`).concat([`${this.table.timeColumn}<=${escape(row[this.table.timeColumn])}`]).join(" AND ");
151151
}
152152

153153
}

0 commit comments

Comments
 (0)