We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c29e36 commit 4f7b551Copy full SHA for 4f7b551
test/integration/connection/test-typecast.js
@@ -4,6 +4,9 @@ const common = require('../../common');
4
const connection = common.createConnection();
5
const assert = require('assert');
6
7
+connection.query('CREATE TEMPORARY TABLE json_test (json_test JSON)');
8
+connection.query('INSERT INTO json_test VALUES (?)', JSON.stringify({ test: 42 }));
9
+
10
connection.query(
11
{
12
sql: 'select "foo uppercase" as foo',
@@ -46,4 +49,18 @@ connection.query(
46
49
}
47
50
);
48
51
52
+connection.query(
53
+ {
54
+ sql: 'SELECT * from json_test',
55
+ typeCast: function(_field, next) {
56
+ return next();
57
+ }
58
+ },
59
+ (err, _rows) => {
60
+ assert.ifError(err);
61
+ assert.equal(_rows[0].test.test, 42);
62
63
+);
64
65
66
connection.end();
0 commit comments