Skip to content

Commit

Permalink
wrote integration test for new error code mentioned in issue sidorare…
Browse files Browse the repository at this point in the history
  • Loading branch information
elimelt committed May 3, 2023
1 parent 303be6c commit b7878c1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/integration/connection/test-insert-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

/**
* Created by Elijah Melton on 2023.05.03
* issue#1924: https://github.com/sidorares/node-mysql2/issues/1924
*/

const common = require('../../common');
const connection = common.createConnection();
const assert = require('assert');

let result;
let errorCodeInvalidJSON;
let errorNumInvalidJSON;


connection.query('CREATE TEMPORARY TABLE json_test (data JSON)');
connection.query('INSERT INTO json_test VALUES (?)', ['{"k": "v"'], err => {
errorCodeInvalidJSON = err.code;
errorNumInvalidJSON = err.errno;
});

connection.query('INSERT INTO json_test VALUES (?)', ['{"k": "v"}'], (err, res) => {
if (err) throw err;
});

connection.query("SELECT * FROM json_test;", [], (err, res) => {
if (err) throw err;
result = res;
connection.end();
})


process.on('exit', () => {
assert.equal(errorCodeInvalidJSON, 'ER_INVALID_JSON_TEXT');
assert.equal(errorNumInvalidJSON, 3140);
assert.equal(result[0].data.k, "v");
});

0 comments on commit b7878c1

Please # to comment.