Skip to content

Commit b5ad716

Browse files
committed
Add test for unnamed placeholder fallback
1 parent af8bbff commit b5ad716

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/integration/connection/test-named-paceholders.js renamed to test/integration/connection/test-named-placeholders.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,23 @@ connection.query('SELECT :a + :a as sum', { a: 2 }, (err, rows) => {
7171
connection.end();
7272
});
7373

74-
const sql = connection.format(
74+
const namedSql = connection.format(
7575
'SELECT * from test_table where num1 < :numParam and num2 > :lParam',
7676
{ lParam: 100, numParam: 2 }
7777
);
78-
assert.equal(sql, 'SELECT * from test_table where num1 < 2 and num2 > 100');
78+
assert.equal(
79+
namedSql,
80+
'SELECT * from test_table where num1 < 2 and num2 > 100'
81+
);
82+
83+
const unnamedSql = connection.format(
84+
'SELECT * from test_table where num1 < ? and num2 > ?',
85+
[2, 100]
86+
);
87+
assert.equal(
88+
unnamedSql,
89+
'SELECT * from test_table where num1 < 2 and num2 > 100'
90+
);
7991

8092
const pool = common.createPool();
8193
pool.config.connectionConfig.namedPlaceholders = true;

0 commit comments

Comments
 (0)