Skip to content

Commit

Permalink
[CONJS-173] permitting providing null as a value without an array
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Aug 23, 2021
1 parent 9c17990 commit 016ef46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cmd/query.js
Expand Up @@ -22,7 +22,7 @@ class Query extends CommonText {
* @param info connection information
*/
start(out, opts, info) {
if (!this.initialValues) {
if (this.initialValues === undefined) {
//shortcut if no parameters
out.startPacket(this);
out.writeInt8(0x03);
Expand Down
14 changes: 14 additions & 0 deletions test/integration/test-pool.js
Expand Up @@ -108,6 +108,20 @@ describe('Pool', () => {
pool.end();
});

it('query with null placeholder', async function () {
const pool = base.createPool({ connectionLimit: 1 });
let rows = await pool.query('select ? as a', [null]);
assert.deepEqual(rows, [{ a: null }]);
await pool.end();
});

it('query with null placeholder no array', async function () {
const pool = base.createPool({ connectionLimit: 1 });
let rows = await pool.query('select ? as a', null);
assert.deepEqual(rows, [{ a: null }]);
await pool.end();
});

it('pool with wrong authentication', function (done) {
if (process.env.srv === 'maxscale' || process.env.srv === 'skysql-ha') this.skip(); //to avoid host beeing blocked
this.timeout(10000);
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test-query.js
Expand Up @@ -20,6 +20,16 @@ describe('basic query', () => {
.catch(done);
});

it('query with null placeholder', async function () {
let rows = await shareConn.query('select ? as a', [null]);
assert.deepEqual(rows, [{ a: null }]);
});

it('query with null placeholder no array', async function () {
let rows = await shareConn.query('select ? as a', null);
assert.deepEqual(rows, [{ a: null }]);
});

it('parameter last', async () => {
const value = "'`\\";
const conn = await base.createConnection();
Expand Down

0 comments on commit 016ef46

Please sign in to comment.