I'm using libsql package to run an introspection query, and it`s failing thinking "%AUTOINCREMENT%" is a column.
The SQL Standard defines "something" to be evaluated as strings, but SQLite is supposed to parse that a string since double-quoted strings are accepted. Ref: "8. Double-quoted String Literals Are Accepted" https://www.sqlite.org/quirks.html
Note that the same queries runs fine on Turso Dashboard's SQL runner.
const Database = require("libsql");
const syncUrl = "libsql://<something>.turso.io";
const authToken = "";
const queries = [
// Original query
'SELECT `name` from `sqlite_master` WHERE sql LIKE "%AUTOINCREMENT%"',
// Test queries
'SELECT `name` from `sqlite_master` WHERE sql LIKE "%AUTOINCREMENT%"', // Original, fails
"SELECT `name` from `sqlite_master` WHERE sql LIKE '%AUTOINCREMENT%'", // Works
'SELECT `name` from `sqlite_master` WHERE `sql` LIKE "%AUTOINCREMENT%"', // Fails
"SELECT `name` from `sqlite_master` WHERE `sql` LIKE '%AUTOINCREMENT%'", // Works
"SELECT name from sqlite_master WHERE sql = CONCAT('%AUTO', 'INCREMENT%')", // Works
'SELECT name from sqlite_master WHERE sql = CONCAT("%AUTO", "INCREMENT%")', // Fails
];
const task = (async function run() {
const db = new Database("./database.sqlite", {
syncUrl,
authToken,
});
db.sync();
console.clear();
for (const query of queries) {
console.log("")
try {
console.log(`${query}\n`);
const result = db.prepare(query).all();
console.error(` > OK`)
//console.table(result);
} catch (err) {
console.error(` > FAILED WITH: ${err.message}`)
}
}
})();
task.catch(console.error);
I'm using
libsql
package to run an introspection query, and it`s failing thinking "%AUTOINCREMENT%" is a column.The SQL Standard defines "something" to be evaluated as strings, but SQLite is supposed to parse that a string since double-quoted strings are accepted. Ref: "8. Double-quoted String Literals Are Accepted" https://www.sqlite.org/quirks.html
Note that the same queries runs fine on Turso Dashboard's SQL runner.
Error is thrown in
databasePrepareSync
call.