Skip to content

Commit 6b1a89f

Browse files
committed
Fix failing tests for single quotes in strings.
Make everything use the same method for escaping. It was couple of inline `.replace` calls before (in base and mysql drivers).
1 parent 0ac5c25 commit 6b1a89f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/driver/base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ module.exports = Base = Class.extend({
174174
columnNames += columnNameArray[index];
175175

176176
if (typeof(valueArray[index]) === 'string') {
177-
values += "'" + valueArray[index].replace("'", "''") + "'";
177+
values += "'" + this.escape(valueArray[index]) + "'";
178178
} else {
179179
values += valueArray[index];
180180
}
@@ -226,6 +226,6 @@ module.exports = Base = Class.extend({
226226
},
227227

228228
escape: function(str) {
229-
return str.replace(/'/g, "\'");
229+
return str.replace(/'/g, "''");
230230
}
231231
});

lib/driver/mysql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ var MysqlDriver = Base.extend({
186186
columnNames += '`' + columnNameArray[index] + '`';
187187

188188
if (typeof(valueArray[index]) === 'string') {
189-
values += "'" + valueArray[index].replace("'", "''") + "'";
189+
values += "'" + this.escape(valueArray[index]) + "'";
190190
} else {
191191
values += valueArray[index];
192192
}

0 commit comments

Comments
 (0)