pgsql-test 4.13.0 → 4.13.2

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/README.md +13 -1
  2. package/package.json +11 -11
package/README.md CHANGED
@@ -191,7 +191,19 @@ db.setContext({
191
191
  });
192
192
  ```
193
193
 
194
- This applies the settings using `SET LOCAL` statements, ensuring they persist only for the current transaction and maintain proper isolation between tests.
194
+ This applies the settings using `SET LOCAL` and `set_config(..., true)` statements, ensuring they persist only for the current transaction and maintain proper isolation between tests.
195
+
196
+ > **⚠️ Important:** `set_config(..., true)` is **transaction-local**. Inside test bodies (`it()` blocks), `beforeEach()` has already started a transaction, so context persists across queries automatically. However, in `beforeAll()` there is no active transaction — each query runs in auto-commit mode and context is lost between calls. If you need context-aware operations in `beforeAll()`, wrap them in explicit `db.begin()` / `db.commit()`:
197
+ >
198
+ > ```ts
199
+ > beforeAll(async () => {
200
+ > ({ db, teardown } = await getConnections());
201
+ > await db.begin();
202
+ > db.setContext({ role: 'authenticated', 'jwt.claims.user_id': '123' });
203
+ > await db.query('SELECT current_user_id()'); // context persists within transaction
204
+ > await db.commit();
205
+ > });
206
+ > ```
195
207
 
196
208
  #### Testing Role-Based Access
197
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-test",
3
- "version": "4.13.0",
3
+ "version": "4.13.2",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution",
6
6
  "main": "index.js",
@@ -55,21 +55,21 @@
55
55
  "test:watch": "jest --watch"
56
56
  },
57
57
  "devDependencies": {
58
- "@pgpmjs/core": "6.17.0",
58
+ "@pgpmjs/core": "6.17.1",
59
59
  "@types/pg": "^8.18.0",
60
60
  "@types/pg-copy-streams": "^1.2.5",
61
61
  "makage": "^0.3.0"
62
62
  },
63
63
  "dependencies": {
64
- "@pgpmjs/env": "^2.22.0",
65
- "@pgpmjs/logger": "^2.10.0",
66
- "@pgpmjs/server-utils": "^3.10.0",
67
- "@pgpmjs/types": "^2.26.0",
64
+ "@pgpmjs/env": "^2.22.1",
65
+ "@pgpmjs/logger": "^2.10.1",
66
+ "@pgpmjs/server-utils": "^3.10.1",
67
+ "@pgpmjs/types": "^2.26.1",
68
68
  "pg": "^8.20.0",
69
- "pg-cache": "^3.9.0",
70
- "pg-env": "^1.13.0",
71
- "pgsql-client": "^3.13.0",
72
- "pgsql-seed": "^2.13.0"
69
+ "pg-cache": "^3.9.1",
70
+ "pg-env": "^1.13.1",
71
+ "pgsql-client": "^3.13.1",
72
+ "pgsql-seed": "^2.13.1"
73
73
  },
74
- "gitHead": "c665e2443ec98da61e9f372cf663cb9973afef4b"
74
+ "gitHead": "ea590e1b9e1ee38c267f8dbbb37aa3f83a5d3fb7"
75
75
  }