oven-sh/bun
View on GitHubAutomatically create directories for the path passed to `new Database`
Open
#3,888 opened on Jul 30, 2023
bun.jsbun:sqliteenhancementgood first issue
Description
What version of Bun is running?
0.7.1
What platform is your computer?
Darwin 21.6.0 x86_64 i386
What steps can reproduce the bug?
-
create a directory called
src -
create a file called
a.tswith this contentsimport { Database } from 'bun:sqlite'; const db = new Database('./i-dont-exist/data.db'); -
bun run ./a.ts -
error should show
What is the expected behavior?
The directory to be created and then the new database file to be created.
What do you see instead?
This error.
➜ paas git:(main) ✗ bun run src/service-registry.ts
136 | if (anonymous && (flags & constants.SQLITE_OPEN_READONLY) !== 0)
137 | throw new Error("Cannot open an anonymous database in read-only mode.");
138 | if (!SQL)
139 | _SQL = SQL = lazy("sqlite");
140 |
141 | this.#handle = SQL.open(anonymous ? ":memory:" : filename, flags), this.filename = filename;
^
error: unable to open database file
at new Database (bun:sqlite:141:19)
at /Users/xo/code/ImLunaHey/paas/src/service-registry.ts:3:11
Additional information
No response