Skip to content

Commit 983034c

Browse files
committed
manually merge upstream
2 parents fe4d08a + 8f193ca commit 983034c

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
},
55
"rules": {
66
"comma-dangle": [2, "never"],
7+
"comma-spacing": ["error", { "before": false, "after": true }],
78
"consistent-return": 2,
89
"eqeqeq": [2, "allow-null"],
910
"indent": [2, 2, { "VariableDeclarator": 2, "SwitchCase": 1 }],

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ node_js:
99
- "3.3"
1010
- "4.8"
1111
- "5.12"
12-
- "6.11"
12+
- "6.13"
1313
- "7.10"
14-
- "8.6"
14+
- "8.9"
15+
- "9.6"
1516
sudo: false
1617
dist: precise
1718
cache:

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.3.1 / 2018-02-24
2+
==================
3+
4+
* Fix incorrectly replacing non-placeholders in SQL
5+
16
2.3.0 / 2017-10-01
27
==================
38

lib/SqlString.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,19 @@ SqlString.format = function format(sql, values, stringifyObjects, timeZone) {
9999
}
100100

101101
var chunkIndex = 0;
102-
var placeholdersRegex = /\?\??/g;
102+
var placeholdersRegex = /\?+/g;
103103
var result = '';
104104
var valuesIndex = 0;
105105
var match;
106106

107107
while (valuesIndex < values.length && (match = placeholdersRegex.exec(sql))) {
108-
var value = match[0] === '??'
108+
var len = match[0].length;
109+
110+
if (len > 2) {
111+
continue;
112+
}
113+
114+
var value = len === 2
109115
? SqlString.escapeId(values[valuesIndex])
110116
: SqlString.escape(values[valuesIndex], stringifyObjects, timeZone);
111117

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sqlstring",
33
"description": "Simple SQL escape and format for MySQL",
4-
"version": "2.3.0",
4+
"version": "2.3.1",
55
"contributors": [
66
"Adri Van Houdt <[email protected]>",
77
"Douglas Christopher Wilson <[email protected]>",
@@ -24,7 +24,7 @@
2424
"devDependencies": {
2525
"beautify-benchmark": "0.2.4",
2626
"benchmark": "2.1.4",
27-
"eslint": "4.8.0",
27+
"eslint": "4.18.1",
2828
"eslint-plugin-markdown": "1.0.0-beta.6",
2929
"nyc": "10.3.2",
3030
"urun": "0.0.8",

test/unit/test-SqlString.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test('SqlString.escape', {
113113
},
114114

115115
'nested arrays are turned into grouped lists': function() {
116-
assert.equal(SqlString.escape([[1,2,3], [4,5,6], ['a', 'b', {nested: true}]]), "(1, 2, 3), (4, 5, 6), ('a', 'b', '[object Object]')");
116+
assert.equal(SqlString.escape([[1, 2, 3], [4, 5, 6], ['a', 'b', {nested: true}]]), "(1, 2, 3), (4, 5, 6), ('a', 'b', '[object Object]')");
117117
},
118118

119119
'nested objects inside arrays are cast to strings': function() {
@@ -278,6 +278,11 @@ test('SqlString.format', {
278278
});
279279
},
280280

281+
'triple question marks are ignored': function () {
282+
var sql = SqlString.format('? or ??? and ?', ['foo', 'bar', 'fizz', 'buzz']);
283+
assert.equal(sql, "'foo' or ??? and 'bar'");
284+
},
285+
281286
'extra question marks are left untouched': function() {
282287
var sql = SqlString.format('? and ?', ['a']);
283288
assert.equal(sql, "'a' and ?");

0 commit comments

Comments
 (0)