Skip to content

Commit 69b7d87

Browse files
authored
fix: apply create options without data directory (#1078)
1 parent 0ad2901 commit 69b7d87

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

.changeset/fresh-options-create.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@electric-sql/pglite': patch
3+
---
4+
5+
Apply the second options argument when calling `PGlite.create(undefined, options)`.

packages/pglite/src/pglite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class PGlite
260260
dataDir: dataDirOrPGliteOptions,
261261
...(options ?? {}),
262262
}
263-
: (dataDirOrPGliteOptions ?? {})
263+
: (dataDirOrPGliteOptions ?? options ?? {})
264264

265265
const pg = new PGlite(resolvedOpts)
266266
await pg.waitReady

packages/pglite/tests/instantiation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { PGlite } from '../dist/index.js'
44
describe('instantiation', () => {
55
testInstatiationMethod('constructor')
66
testInstatiationMethod('static `create` factory')
7+
8+
it('should apply options when the data dir is undefined', async () => {
9+
const pg = await PGlite.create(undefined, { debug: 1 })
10+
11+
expect(pg.debug).toBe(1)
12+
})
713
})
814

915
function testInstatiationMethod(

0 commit comments

Comments
 (0)