Created
May 6, 2020 00:47
-
-
Save nmay231/af28b35d412a365c1d86fb6c7e33c60f to your computer and use it in GitHub Desktop.
better-sqlite3 trigger bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE Test ( | |
id integer primary key autoincrement, | |
data text not null, | |
_last_updated datetime default current_timestamp | |
); | |
CREATE TRIGGER update_test_timestamp | |
AFTER UPDATE ON Test BEGIN | |
UPDATE Test SET _last_updated = datetime("now") WHERE id = new.id; | |
END; | |
INSERT INTO Test(data) VALUES("blah blah blah"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connect = require('better-sqlite3') | |
const db = connect('test.db', { fileMustExist: true }) | |
db.prepare('UPDATE Test SET data=? WHERE id=?').run('blah blah 3.0', 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "sqlite-bug", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"better-sqlite3": "^7.0.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment