oven-sh/bun

Automatically create directories for the path passed to `new Database`

Open

#3 888 ouverte le 30 juil. 2023

Voir sur GitHub
 (10 commentaires) (0 réactions) (0 assignés)Rust (4 486 forks)batch import
bun.jsbun:sqliteenhancementgood first issue

Métriques du dépôt

Stars
 (90 348 stars)
Métriques de merge PR
 (Merge moyen 1j 17h) (357 PRs mergées en 30 j)

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.ts with this contents

    import { 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

Guide contributeur