Skip to content

Commit b098d49

Browse files
authored
Merge pull request #652 from sidorares/type-cast-null
test(typecast): first null value, corrupts next field
2 parents 7337107 + f68bd76 commit b098d49

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ matrix:
99
include:
1010
- node_js: "4.8"
1111
env: LINT=0
12-
- node_js: "6.10"
12+
- node_js: "6.11"
1313
env: LINT=0
14-
- node_js: "7.10"
15-
env: LINT=0
16-
- node_js: "8.4"
14+
- node_js: "8.0"
1715
env: LINT=1
1816

1917
cache:

appveyor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ environment:
77
LINT: 0
88

99
matrix:
10-
- nodejs_version: "6.10"
11-
- nodejs_version: "7.10"
12-
- nodejs_version: "8.1"
10+
- nodejs_version: "6.11"
11+
- nodejs_version: "8.6"
1312
LINT: 1
1413

1514
services:

lib/compile_text_parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function readCodeFor(type, charset, encodingExpr, config, options) {
153153
case Types.DOUBLE:
154154
return 'packet.parseLengthCodedFloat()';
155155
case Types.NULL:
156-
return 'null; packet.skip(1)';
156+
return 'packet.readLengthCodedNumber()';
157157
case Types.DECIMAL:
158158
case Types.NEWDECIMAL:
159159
if (config.decimalNumbers) {

test/integration/connection/test-typecast.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,18 @@ connection.query(
3030
}
3131
);
3232

33+
connection.query(
34+
{
35+
sql: 'SELECT NULL as test, 6 as value;',
36+
typeCast: function(field, next) {
37+
return next();
38+
}
39+
},
40+
function(err, _rows) {
41+
assert.ifError(err);
42+
assert.equal(_rows[0].test, null);
43+
assert.equal(_rows[0].value, 6);
44+
}
45+
);
46+
3347
connection.end();

0 commit comments

Comments
 (0)