Skip to content

Commit 1cea508

Browse files
committed
change how readCode is applied in typeCast generated wrapper. Fixes #1418
1 parent 4f7b551 commit 1cea508

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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
}

test/integration/connection/test-typecast.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,31 @@ connection.query(
4949
}
5050
);
5151

52+
5253
connection.query(
5354
{
5455
sql: 'SELECT * from json_test',
5556
typeCast: function(_field, next) {
56-
return next();
57+
return next();
5758
}
5859
},
5960
(err, _rows) => {
6061
assert.ifError(err);
61-
assert.equal(_rows[0].test.test, 42);
62+
assert.equal(_rows[0].json_test.test, 42);
6263
}
6364
);
6465

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+
);
6578

6679
connection.end();

0 commit comments

Comments
 (0)