Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a107dc6

Browse filesBrowse files
committed
Fix bad handling of null values
Null values were causing problems in columns when typecasting them. This patch makes sure null values are never typecasted.
1 parent 0bf10a7 commit a107dc6
Copy full SHA for a107dc6

File tree

Expand file treeCollapse file tree

2 files changed

+4
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-3
lines changed

‎lib/mysql/query.js

Copy file name to clipboardExpand all lines: lib/mysql/query.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Query.prototype._handlePacket = function(packet) {
6767

6868
if (remaining == 0) {
6969
self._rowIndex++;
70-
if (self.typeCast) {
70+
if (self.typeCast && buffer !== null) {
7171
switch (field.fieldType) {
7272
case Query.FIELD_TYPE_TIMESTAMP:
7373
case Query.FIELD_TYPE_DATE:

‎test/system/test-client-query.js

Copy file name to clipboardExpand all lines: test/system/test-client-query.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ client.query(
4747
var query = client.query(
4848
'INSERT INTO '+TEST_TABLE+' '+
4949
'SET title = ?, text = ?, created = ?',
50-
['another entry', 'because 2 entries make a better test', '2010-08-16 12:42:15']
50+
['another entry', 'because 2 entries make a better test', null]
5151
);
5252

5353
query.on('end', gently.expect(function insertOkCb(packet) {
@@ -63,7 +63,8 @@ var query = client.query(
6363
assert.equal(results.length, 2);
6464
assert.equal(results[1].title, 'another entry');
6565
assert.ok(typeof results[1].id == 'number');
66-
assert.ok(results[1].created instanceof Date);
66+
assert.ok(results[0].created instanceof Date);
67+
assert.strictEqual(results[1].created, null);
6768
client.end();
6869
})
6970
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.