@mikro-orm/pglite 7.1.5-dev.3 → 7.1.5-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/PgliteConnection.js +13 -11
  2. package/package.json +3 -3
@@ -40,14 +40,16 @@ export class PgliteConnection extends AbstractSqlConnection {
40
40
  const dataDir = options.dataDir ?? dbName;
41
41
  const parsers = { ...createPostgreSqlTypeParsers(s => array.parse(s)), ...options.parsers };
42
42
  this.#ownsPglite = !userPglite;
43
- // Skip `pglite.close()` (called by kysely's `PGliteDriver.destroy()`) when:
44
- // - the user owns the instance (closing it is their responsibility), or
45
- // - we hold an in-memory DB whose data would otherwise be lost on
46
- // reconnect (e.g. test harnesses that drive `orm.close()` + `orm.connect()`).
47
- // For file/IDB-backed instances we let kysely close so file handles / IDB
48
- // connections are released; we drop our cached promise in `close()` below
49
- // so the next dialect-construction rebuilds the PGlite instance.
50
- this.#neuterClose = !this.#ownsPglite || isInMemoryDataDir(dataDir);
43
+ // Skip `pglite.close()` (called by kysely's `PGliteDriver.destroy()`) only
44
+ // when the user owns the instance closing it is their responsibility, and
45
+ // patching `close` on it directly would orphan it (its real `close` would
46
+ // stay neutered after `orm.close()`). Instances we own (in-memory or
47
+ // file/IDB-backed) get really closed so the underlying WASM / file handle /
48
+ // IDB resources are released; we drop our cached promise in `close()` below
49
+ // so the next dialect-construction rebuilds the PGlite instance. In-memory
50
+ // data does not survive `orm.close()`, consistent with other in-memory
51
+ // drivers (e.g. SQLite `:memory:`).
52
+ this.#neuterClose = !this.#ownsPglite;
51
53
  if (!this.#pglite) {
52
54
  if (userPglite) {
53
55
  this.#pglite = typeof userPglite === 'function' ? Promise.resolve(userPglite()) : Promise.resolve(userPglite);
@@ -88,9 +90,9 @@ export class PgliteConnection extends AbstractSqlConnection {
88
90
  }
89
91
  async close(force) {
90
92
  await super.close(force);
91
- // Persistent backings (file/IDB) we own get really closed by kysely — drop
92
- // the cached promise so a subsequent reconnect rebuilds a fresh instance
93
- // (which then re-reads the persisted data from disk / IDB).
93
+ // Instances we own get really closed by kysely — drop the cached promise so a
94
+ // subsequent reconnect rebuilds a fresh instance (file/IDB backings re-read the
95
+ // persisted data; in-memory starts empty, matching other in-memory drivers).
94
96
  if (this.#ownsPglite && !this.#neuterClose) {
95
97
  this.#pglite = undefined;
96
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/pglite",
3
- "version": "7.1.5-dev.3",
3
+ "version": "7.1.5-dev.5",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@electric-sql/pglite": "0.5.1",
52
- "@mikro-orm/sql": "7.1.5-dev.3",
52
+ "@mikro-orm/sql": "7.1.5-dev.5",
53
53
  "kysely": "0.29.2",
54
54
  "postgres-array": "3.0.4",
55
55
  "postgres-date": "2.1.0",
@@ -59,7 +59,7 @@
59
59
  "@mikro-orm/core": "^7.1.4"
60
60
  },
61
61
  "peerDependencies": {
62
- "@mikro-orm/core": "7.1.5-dev.3"
62
+ "@mikro-orm/core": "7.1.5-dev.5"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">= 22.17.0"