Skip to content

Commit 35eb2df

Browse files
committed
special char issue
1 parent 71b41d7 commit 35eb2df

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/api/migratepg.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,23 @@ console.log(payload[fieldname]['old'])
170170
await client.query(sql);
171171
// sql = `update ${table} set ${Object.keys(payload).map((key) => `\"${key}\"='${payload[key]['new']}'`).join(', ')} where ${Object.keys(payload).map((key) => `\"${key}\"='${payload[key]['old']}'`).join(' AND ')} ;` // "update <schema>:<table> set col_1=val_1, col_2=val_2, ... where primary_key_col=primary_key_val"
172172

173-
sql = `update "${table}" set ${columnNames.map(x => `"${x}"=$${x + 1}`).join(',')} where ${oldconditionstr} ;`
173+
// sql = `update "${table}" set ${columnNames.map(x => `"${x}"=$${x + 1}`).join(',')} where ${oldconditionstr} ;`
174174
const values = [];
175+
var updatestr = ""
176+
counter = 1
177+
buffferupcond=0
175178
columnNames.forEach((colName) => {
176179
colobj = payload[colName]
177180
values.push(colobj.new);
181+
if (buffferupcond == 1) {
182+
updatestr = updatestr + " , "
183+
}
184+
updatestr = updatestr + "\"" + colName + "\"= \$" + counter + " "
185+
buffferupcond = 1
186+
counter = counter + 1
178187
});
188+
189+
sql = `update "${table}" set ${updatestr} where ${oldconditionstr} ;`
179190
// sql = `update "${table}" set ${setdatastr} where ${oldconditionstr} ;`
180191
console.log("sqlstring ..............................");
181192
console.log(sql);

0 commit comments

Comments
 (0)