Skip to content

Commit 145d45f

Browse files
committed
Merge branch 'master' of github.com:sidorares/node-mysql2
2 parents 20969be + 7ee4323 commit 145d45f

File tree

5 files changed

+34
-145
lines changed

5 files changed

+34
-145
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ lib-cov
88
*.gz
99
.DS_Store
1010
.idea/
11+
.vscode/
1112
.npmrc
1213
mysqldata/
1314

benchmarks/run-unit.js

Lines changed: 0 additions & 143 deletions
This file was deleted.

lib/parsers/text_parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ function compile(fields, options, config) {
119119
return _this.packet.parseGeometryValue();
120120
},
121121
readNext: function() {
122-
return _this.${readCode};
122+
const packet = _this.packet;
123+
return ${readCode};
123124
}
124125
};`);
125126
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
1212
"lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"",
1313
"test": "node ./test/run.js",
14-
"benchmark": "./benchmarks/run-unit.js",
14+
"benchmark": "node ./benchmarks/benchmark.js",
1515
"prettier": "prettier --single-quote --trailing-comma none --write \"{lib,examples,test}/**/*.js\"",
1616
"prettier:docs": "prettier --single-quote --trailing-comma none --write README.md documentation/*",
1717
"precommit": "lint-staged",

test/integration/connection/test-typecast.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const common = require('../../common');
44
const connection = common.createConnection();
55
const assert = require('assert');
66

7+
connection.query('CREATE TEMPORARY TABLE json_test (json_test JSON)');
8+
connection.query('INSERT INTO json_test VALUES (?)', JSON.stringify({ test: 42 }));
9+
710
connection.query(
811
{
912
sql: 'select "foo uppercase" as foo',
@@ -46,4 +49,31 @@ connection.query(
4649
}
4750
);
4851

52+
53+
connection.query(
54+
{
55+
sql: 'SELECT * from json_test',
56+
typeCast: function(_field, next) {
57+
return next();
58+
}
59+
},
60+
(err, _rows) => {
61+
assert.ifError(err);
62+
assert.equal(_rows[0].json_test.test, 42);
63+
}
64+
);
65+
66+
connection.execute(
67+
{
68+
sql: 'SELECT * from json_test',
69+
typeCast: function(_field, next) {
70+
return next();
71+
}
72+
},
73+
(err, _rows) => {
74+
assert.ifError(err);
75+
assert.equal(_rows[0].json_test.test, 42);
76+
}
77+
);
78+
4979
connection.end();

0 commit comments

Comments
 (0)