Skip to content

Commit f7afc64

Browse files
authored
Merge pull request #638 from sidorares/text-protocol-null-int
parseLengthCodedIntString to return null instead of empty string for null columns
2 parents c9e5926 + b6cac7b commit f7afc64

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/packets/packet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ Packet.prototype.parseLengthCodedInt = function(supportBigNumbers) {
669669
};
670670

671671
Packet.prototype.parseLengthCodedIntString = function() {
672-
return this.readString(this.readLengthCodedNumber(), 'binary');
672+
return this.readLengthCodedString('binary');
673673
};
674674

675675
Packet.prototype.parseLengthCodedFloat = function() {

test/integration/connection/test-binary-longlong.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ var conn = common.createConnection();
77
conn.query(
88
'CREATE TEMPORARY TABLE `tmp_longlong` ( ' +
99
' `id` int(11) NOT NULL AUTO_INCREMENT, ' +
10-
' `ls` BIGINT SIGNED NOT NULL, ' +
11-
' `lu` BIGINT UNSIGNED NOT NULL, ' +
10+
' `ls` BIGINT SIGNED, ' +
11+
' `lu` BIGINT UNSIGNED, ' +
1212
' PRIMARY KEY (`id`) ' +
1313
' ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8'
1414
);
@@ -17,7 +17,8 @@ var values = [
1717
['10', '10'],
1818
['-11', '11'],
1919
['965432100123456789', '1965432100123456789'],
20-
['-965432100123456789', '2965432100123456789']
20+
['-965432100123456789', '2965432100123456789'],
21+
[null, null]
2122
];
2223

2324
conn.connect(function(err) {
@@ -38,21 +39,24 @@ conn.connect(function(err) {
3839
{ id: 1, ls: 10, lu: 10 },
3940
{ id: 2, ls: -11, lu: 11 },
4041
{ id: 3, ls: 965432100123456800, lu: 1965432100123456800 },
41-
{ id: 4, ls: -965432100123456800, lu: 2965432100123457000 }
42+
{ id: 4, ls: -965432100123456800, lu: 2965432100123457000 },
43+
{ id: 5, ls: null, lu: null }
4244
];
4345

4446
var bigNums_bnStringsTrueFalse = [
4547
{ id: 1, ls: 10, lu: 10 },
4648
{ id: 2, ls: -11, lu: 11 },
4749
{ id: 3, ls: '965432100123456789', lu: '1965432100123456789' },
48-
{ id: 4, ls: '-965432100123456789', lu: '2965432100123456789' }
50+
{ id: 4, ls: '-965432100123456789', lu: '2965432100123456789' },
51+
{ id: 5, ls: null, lu: null }
4952
];
5053

5154
var bigNums_bnStringsTrueTrue = [
5255
{ id: 1, ls: 10, lu: 10 },
5356
{ id: 2, ls: -11, lu: 11 },
5457
{ id: 3, ls: '965432100123456789', lu: '1965432100123456789' },
55-
{ id: 4, ls: '-965432100123456789', lu: '2965432100123456789' }
58+
{ id: 4, ls: '-965432100123456789', lu: '2965432100123456789' },
59+
{ id: 5, ls: null, lu: null }
5660
];
5761

5862
function check() {

0 commit comments

Comments
 (0)