@vibeorm/adapter-pg 1.2.0 → 1.3.0
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/package.json +2 -2
- package/src/index.ts +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeorm/adapter-pg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "node-postgres adapter for VibeORM — use VibeORM with pg on Bun or Node.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/vibeorm/vibeorm/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@vibeorm/runtime": "1.
|
|
34
|
+
"@vibeorm/runtime": "1.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"pg": ">=8"
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { DatabaseAdapter, QueryResult, TransactionOptions } from "@vibeorm/runtime";
|
|
9
|
+
import { PgArray } from "@vibeorm/runtime";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Options for creating a pg adapter.
|
|
@@ -142,8 +143,14 @@ class PgArrayParam {
|
|
|
142
143
|
*/
|
|
143
144
|
function serializeParams(params: { values: unknown[] }): unknown[] {
|
|
144
145
|
return params.values.map((v) => {
|
|
145
|
-
// Unwrap
|
|
146
|
-
|
|
146
|
+
// Unwrap any array-param wrapper — covers BOTH the adapter's internal
|
|
147
|
+
// PgArrayParam (set by this adapter's formatArrayParam) AND the runtime's
|
|
148
|
+
// PgArray marker. The runtime's `client.ts` normally unwraps PgArray into
|
|
149
|
+
// PgArrayParam via `adapter.formatArrayParam(...)`, but recognising both
|
|
150
|
+
// here is defence-in-depth — any future executor path that bypasses that
|
|
151
|
+
// unwrap step would otherwise silently double-serialise the array as JSON.
|
|
152
|
+
// Bug 3 — see .ai/bug-report-2026-05-24.md.
|
|
153
|
+
if (v instanceof PgArrayParam || v instanceof PgArray) {
|
|
147
154
|
return v.values;
|
|
148
155
|
}
|
|
149
156
|
// JSON.stringify plain objects and arrays for json/jsonb columns
|
|
@@ -182,7 +189,8 @@ function serializeParams(params: { values: unknown[] }): unknown[] {
|
|
|
182
189
|
*/
|
|
183
190
|
function serializeParamsRaw(params: { values: unknown[] }): unknown[] {
|
|
184
191
|
return params.values.map((v) => {
|
|
185
|
-
|
|
192
|
+
// Recognise both wrappers — see serializeParams for rationale (Bug 3).
|
|
193
|
+
if (v instanceof PgArrayParam || v instanceof PgArray) {
|
|
186
194
|
return v.values;
|
|
187
195
|
}
|
|
188
196
|
// Plain JS arrays pass through — pg converts to PG array literal natively.
|