Skip to content

Commit

Permalink
fix: support passing file:// URI when SQLite was compiled with `SQLIT…
Browse files Browse the repository at this point in the history
…E_USE_URI=1`

I'm trying to use `better-sqlite3` with an SQLite that is compiled with
`SQLITE_USE_URI=1`:

```js
const db = SQLite(`file:///foo/bar?vfs=myfs&mode=ro&immutable=1`);
```

This, however, doesn't work right now, since there's an erroneous
assertion in the database creation.

With this patch, I can successfully connect to database.

References WiseLibs#483
  • Loading branch information
aslushnikov committed Nov 21, 2023
1 parent 6694cf4 commit c5f0f6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Database(filenameGiven, options) {
}

// Make sure the specified directory exists
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
if (!filename.startsWith('file://') && !anonymous && !fs.existsSync(path.dirname(filename))) {
throw new TypeError('Cannot open database because the directory does not exist');
}

Expand Down

0 comments on commit c5f0f6a

Please sign in to comment.