Commit 92ea64c5 by Konstantin Käfer

support buffers as first parameter

fixes #108

issue is that we perform auto-detection of the parameter style based on
the type of the first parameter. if it is an object, we switch to the
object syntax. however, buffers are also objects, so we have to special
case them too like RegExp and Date.
parent 3d8acd39
......@@ -215,7 +215,7 @@ template <class T> T* Statement::Bind(const Arguments& args, int start, int last
baton->parameters.push_back(BindParameter(array->Get(i), pos));
}
}
else if (!args[start]->IsObject() || args[start]->IsRegExp() || args[start]->IsDate()) {
else if (!args[start]->IsObject() || args[start]->IsRegExp() || args[start]->IsDate() || Buffer::HasInstance(args[start])) {
// Parameters directly in array.
// Note: bind parameters start with 1.
for (int i = start, pos = 1; i < last; i++, pos++) {
......
var sqlite3 = require('..'),
assert = require('assert');
describe('buffer', function() {
var db;
// before(function() {
// });
it('should insert blobs', function(done) {
db = new sqlite3.Database(':memory:');
db.serialize(function () {
db.run("CREATE TABLE lorem (info BLOB)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
stmt.on('error', function (err) {
throw err;
});
var buff = new Buffer(2);
stmt.run('a');
stmt.finalize();
});
db.close(done);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment