WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

Applying the Check Constraint with a String in Double Quotes Does Not Work #1092

Closed Talfa5-5 closed 9 months ago

Talfa5-5 commented 9 months ago
const sqlite = require("better-sqlite3");
const database = sqlite("./database.db");
database.prepare(`CREATE TABLE strings ("string" text, CHECK (string is not "abc"))`).run();

The code above throws the error Uncaught SqliteError: no such column: abc. However, running the same SQL query with sqlite3.exe works. Now, I know that I can avoid this error by enclosing "abc" in single quotes instead of double quotes. But should this discrepancy in behaviour between better-sqlite3 and sqlite3.exe be considered a bug?

Prinzhorn commented 9 months ago

Now, I know that I can avoid this error by enclosing "abc" in single quotes instead of double quotes. But should this discrepancy in behaviour between better-sqlite3 and sqlite3.exe be considered a bug?

https://github.com/WiseLibs/better-sqlite3/blob/master/docs/compilation.md#bundled-configuration

SQLITE_DQS=0

https://www.sqlite.org/quirks.html#dblquote

Since 3.41.0 (2023-02-21) your SQL also does not work in the CLI.

Talfa5-5 commented 9 months ago

Oh, never mind then.