forked from sidorares/node-mysql2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote integration test for new error code mentioned in issue sidorare…
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); |