Skip to content

Commit 2de6f24

Browse files
authored
Merge pull request #349 from sushantdhiman/geom-parse-issue
Failing test for geometry typeCast issue
2 parents b534e15 + 9f1e446 commit 2de6f24

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

lib/compile_text_parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function compile (fields, options, config) {
2121
table: field.table,
2222
name: field.name,
2323
string: function() { return packet.readLengthCodedString(); },
24-
buffer: function () { return this.parser.parseLengthCodedBuffer(); },
25-
geometry: function () { return this.parser.parseGeometryValue(); }
24+
buffer: function () { return packet.readLengthCodedBuffer(); },
25+
geometry: function () { return packet.parseGeometryValue(); }
2626
};
2727
};
2828

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var common = require('../../common');
2+
var connection = common.createConnection();
3+
var assert = require('assert');
4+
5+
connection.query({
6+
sql: 'select GeomFromText(\'POINT(11 0)\') as foo',
7+
typeCast: function (field, next) {
8+
if (field.type === 'GEOMETRY') {
9+
return field.geometry();
10+
}
11+
return next();
12+
}
13+
}, function(err, res) {
14+
assert.ifError(err);
15+
assert.deepEqual(res[0].foo, { x: 11, y: 0 });
16+
});
17+
18+
connection.query({
19+
sql: 'select GeomFromText(\'POINT(11 0)\') as foo',
20+
typeCast: function (field, next) {
21+
if (field.type === 'GEOMETRY') {
22+
return field.buffer();
23+
}
24+
return next();
25+
}
26+
}, function(err, res) {
27+
assert.ifError(err);
28+
assert.equal(Buffer.isBuffer(res[0].foo), true);
29+
});
30+
31+
connection.end();

0 commit comments

Comments
 (0)