I got a Node script with an Express server, im trying to insert a new entry into a Table. If got folloing setup:
db.run('CREATE TABLE lists(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL)');
...
db.get(`INSERT INTO lists (name) VALUES (?) RETURNING *;`, [name], (err, row) => {
...
});
And the Insert statement throws:
Error: SQLITE_ERROR: near "RETURNING": syntax error
--> in Database#get('INSERT INTO lists (name) VALUES (?) RETURNING *;', [ 'Testing' ], [Function (anonymous)])
but this should be working according to the sqlite wiki
any advise?
Support for the RETURNING
clause was added in Sqlite 3.35.
"Add support for the RETURNING clause on DELETE, INSERT, and UPDATE statements."
While you have Sqlite 3.36 installed in your operating system's environment, it seems your Node environment has an older version of the sqlite3
npm package which has Sqlite 3.34.
On GitHub, as of early November 2021, the sqlite3
package version 5.0.2
for npm was released in February 2021 with an older version of Sqlite.
node-sqlite3
package with Sqlite 3.36 yet.node-sqlite3
does have a commit that updated Sqlite to 3.36 but no release has been made yet.