-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
needs investigationrequires further investigation before determining if it is an issue or notrequires further investigation before determining if it is an issue or notnode compatnode:sqliteIssues related to the `node:sqlite` moduleIssues related to the `node:sqlite` module
Description
Version: Deno 2.5.0
It works on node 24 but fails on Deno 2.5.0 (test files below):
❯ deno -A create.mjs
Databases created: main.sqlite, other.sqlite
❯ node test.mjs
Node attached rows: [ [Object: null prototype] { value: 'hello from other' } ]
❯ deno -A test.mjs
error: Uncaught (in promise) Error: too many attached databases - max 0
db.exec("ATTACH DATABASE 'other.sqlite' AS other;");
^
In read-only connections that rule makes sense, however, Deno is applying it to all connections in:
deno/ext/node/ops/sqlite/database.rs
Line 348 in 6050aea
conn.set_limit(Limit::SQLITE_LIMIT_ATTACHED, 0)?; |
fn open_db(
state: &mut OpState,
readonly: bool,
location: &str,
allow_extension: bool,
) -> Result<rusqlite::Connection, SqliteError> {
if readonly {
...
conn.set_limit(Limit::SQLITE_LIMIT_ATTACHED, 0)?;
return Ok(conn);
}
...
conn.set_limit(Limit::SQLITE_LIMIT_ATTACHED, 0)?; // <---- This line is the culprit
Ok(conn)
}
test.mjs
import { DatabaseSync } from "node:sqlite";
const db = new DatabaseSync("main.sqlite");
db.exec("ATTACH DATABASE 'other.sqlite' AS other;");
const rows = db.prepare("SELECT * FROM other.test;").all();
console.log("Attached rows:", rows);
create.mjs
import { DatabaseSync } from "node:sqlite";
// main.sqlite with table main_table
const main = new DatabaseSync("main.sqlite");
main.exec("DROP TABLE IF EXISTS main_table;");
main.exec("CREATE TABLE main_table (value TEXT);");
main.prepare("INSERT INTO main_table (value) VALUES (?)").run("hello from main");
main.close();
// other.sqlite with table test
const other = new DatabaseSync("other.sqlite");
other.exec("DROP TABLE IF EXISTS test;");
other.exec("CREATE TABLE test (value TEXT);");
other.prepare("INSERT INTO test (value) VALUES (?)").run("hello from other");
other.close();
console.log("Databases created: main.sqlite, other.sqlite");
Metadata
Metadata
Assignees
Labels
needs investigationrequires further investigation before determining if it is an issue or notrequires further investigation before determining if it is an issue or notnode compatnode:sqliteIssues related to the `node:sqlite` moduleIssues related to the `node:sqlite` module