Skip to content

Commit

Permalink
fix in null bitmap calculation for 8,16,24,.. params sidorares#25
Browse files Browse the repository at this point in the history
  • Loading branch information
sidorares committed Jul 15, 2013
1 parent ffc975c commit fe2ab0b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/packets/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Execute.prototype.toPacket = function()
if (this.parameters[i] !== null) {
if (this.parameters[i].constructor === Date) {
var d = this.parameters[i];
// TODO: move to asMysqlDateTime()
this.parameters[i] = [d.getFullYear(), d.getMonth() + 1, d.getDay()].join('-') +
' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':');
}
Expand Down Expand Up @@ -71,7 +72,7 @@ Execute.prototype.toPacket = function()
bitValue = 1;
}
}
if (bitValue != 256)
if (bitValue != 1)
packet.writeInt8(bitmap);

// TODO: explain meaning of the flag
Expand Down
22 changes: 22 additions & 0 deletions test/integration/connection/test-execute-null-bitmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var common = require('../../common');
var connection = common.createConnection();
var assert = require('assert');

var params = [1, 2];
var query = 'select ? + ?';

function dotest() {
connection.execute(query + ' as t', params, function(err, _rows, _fields) {
assert.equal(err, null);
if (params.length < 50) {
assert.equal(_rows[0].t, params.reduce(function(x,y) {return x+y;}));
query += ' + ?';
params.push(params.length);
dotest();
} else {
connection.end();
}
});
}

dotest();

0 comments on commit fe2ab0b

Please sign in to comment.