const database = require('better-sqlite3');
const db = new database('example.db');
db.on('open', () => {
db.prepare('CREATE TABLE result(d BLOB, t integer);').run()
const st = db.prepare('INSERT INTO result (d, t) VALUES (?, ?)')
st.run([null, 1])
st.run([new Buffer(0), 2])
console.log('* in result:\n\t', db.prepare('SELECT * FROM result').all())
console.log('SELECT d = null:\n\t', db.prepare('SELECT * FROM result WHERE d = ?').all(null))
console.log('SELECT d = new Buffer(0):\n\t', db.prepare('SELECT * from result where d = ?').all(new Buffer(0)))
console.log('SELECT d is new Buffer(0):\n\t', db.prepare('SELECT * from result where d is ?').all(new Buffer(0)))
console.log('SELECT d is null:\n\t', db.prepare('SELECT * from result where d is ?').all(null))
});
output:
* in result:
[ { d: null, t: 1 }, { d: null, t: 2 } ]
SELECT d = null:
[]
SELECT d = new Buffer(0):
[]
SELECT d is new Buffer(0):
[ { d: null, t: 1 }, { d: null, t: 2 } ]
SELECT d is null:
[ { d: null, t: 1 }, { d: null, t: 2 } ]
I can't reproduce this behavior. Which version of better-sqlite3 and Node.js are you using?
Node.js v6.6.0,
Linux: Ubuntu 16.04
[email protected]
I update to master branch but bug are repeated.
After some testing, I've determined that the bug was introduced in Node.js v6.6.0, but fixed in v6.7.0. It also has the correct behavior in v6.5.0 and previous versions.
So either downgrade or upgrade your version of Node.js. I don't think there's anything else we can do about the issue.
Thanks. Now it's working good.
Most helpful comment
After some testing, I've determined that the bug was introduced in Node.js
v6.6.0, but fixed inv6.7.0. It also has the correct behavior inv6.5.0and previous versions.So either downgrade or upgrade your version of Node.js. I don't think there's anything else we can do about the issue.