@vibeorm/adapter-bun 2.1.0 → 2.1.1
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.
- package/README.md +21 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,6 +42,27 @@ await db.$disconnect();
|
|
|
42
42
|
|
|
43
43
|
`Date` parameters are spelled as UTC ISO text on both paths: bun:sql's own serializer for a `date`-typed parameter is `Date#toString()`, which the server rejects in every host time zone. Zone-less columns (`@db.Timestamp(n)`, `@db.Date`) therefore hold the UTC wall-clock on write — the contract shared with node-postgres, PGlite and Prisma. On read, bun:sql is UTC from **Bun 1.4.1**; earlier Bun versions parse zone-less timestamp text as host-local time (1.3.x: scalars on parameterless statements and every array element; 1.4.0: array elements), and bun:sql has no per-query parser hook the adapter could use to correct it. On Bun < 1.4.1 keep the process on `TZ=UTC` when the schema has zone-less columns, or upgrade (`docs/dialect-notes.md` "DateTime without time zone on postgres").
|
|
44
44
|
|
|
45
|
+
## Raw parameters
|
|
46
|
+
|
|
47
|
+
bun:sql types every parameter by the OID the server infers for its slot, and for a `json`/`jsonb` slot it JSON-encodes **whatever JavaScript value is bound** — an object becomes the document, and a string that already holds JSON text becomes a JSON *string* (double-encoded). node-postgres sends a string as text regardless of the slot, so the same raw statement stores the document there. Measured on Bun 1.4.3 / PostgreSQL 18 (`tests/raw-jsonb.live.test.ts` here and in `@vibeorm/adapter-pg`):
|
|
48
|
+
|
|
49
|
+
| `$executeRaw` … `VALUES (${value}::jsonb)` | adapter-bun stores | adapter-pg stores |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `{ a: 1 }` (JS object) | `object` | `object` |
|
|
52
|
+
| `'{"a":1}'` (pre-encoded text) | **`string`** | `object` |
|
|
53
|
+
| `'{"a":1}'` through `${value}::text::jsonb` | `object` | `object` |
|
|
54
|
+
|
|
55
|
+
Bind the object itself, or spell the slot `::text::jsonb` when you bind pre-encoded text — that is the portable form, and it is what the ORM path renders for every `Json` field (`jsonParamCast` in the postgres dialect), which is why `Json` columns behave identically on both adapters. A JS **array** on the raw path is rendered as a PostgreSQL array literal (for `= ANY($1)`), so a JSON array bound into a json column from raw SQL needs `JSON.stringify` plus the `::text::jsonb` spelling.
|
|
56
|
+
|
|
57
|
+
## Session lifetime on `$disconnect()`
|
|
58
|
+
|
|
59
|
+
`disconnect()` rolls back an open raw transaction, releases its reserved connection and closes the pool with bun:sql's `close()`, which waits for in-flight statements to finish. The promise resolves once the client sockets are shut; PostgreSQL removes the sessions from `pg_stat_activity` a few milliseconds later (0–5 ms measured on Bun 1.4.3, the same window node-postgres' `pool.end()` has). `tests/session-lifetime.live.test.ts` pins that every session the adapter can hold — pool, options-transaction connection, raw-transaction session — is gone after `disconnect()`, with a bounded poll.
|
|
60
|
+
|
|
61
|
+
Two things that are NOT the adapter's doing but look like a leak:
|
|
62
|
+
|
|
63
|
+
- A `DROP DATABASE` issued from another connection in the same millisecond can still see a closing session and refuse with SQLSTATE 55006. Poll `pg_stat_activity` for your `application_name` first, or use `DROP DATABASE … WITH (FORCE)` (PostgreSQL 13+).
|
|
64
|
+
- bun:sql never closes idle connections by default (`idleTimeout: 0`), whereas node-postgres reaps an idle client after 10 s. An adapter you never `disconnect()` therefore holds its sessions for the life of the process on bun:sql, where node-postgres would have quietly dropped them.
|
|
65
|
+
|
|
45
66
|
## Runtime support
|
|
46
67
|
|
|
47
68
|
| Runtime | Supported |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeorm/adapter-bun",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "bun:sql (Postgres) adapter for VibeORM v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"bun": ">=1.2.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vibeorm/runtime": "2.
|
|
45
|
-
"@vibeorm/schema": "2.1.
|
|
46
|
-
"@vibeorm/sql": "2.1.
|
|
44
|
+
"@vibeorm/runtime": "2.2.0",
|
|
45
|
+
"@vibeorm/schema": "2.1.1",
|
|
46
|
+
"@vibeorm/sql": "2.1.1"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|