@vibeorm/adapter-bun 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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.ts +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibeorm/adapter-bun",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Bun-native database adapter for VibeORM using bun:sql",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -33,7 +33,7 @@
33
33
  "bun": ">=1.1.0"
34
34
  },
35
35
  "dependencies": {
36
- "@vibeorm/runtime": "1.2.0"
36
+ "@vibeorm/runtime": "1.3.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { DatabaseAdapter, QueryResult, TransactionOptions } from "@vibeorm/runtime";
10
+ import { PgArray } from "@vibeorm/runtime";
10
11
 
11
12
  export type BunAdapterOptions = {
12
13
  /** PostgreSQL connection URL. Falls back to DATABASE_URL env var if not provided. */
@@ -387,12 +388,25 @@ export function bunAdapter(options?: BunAdapterOptions): DatabaseAdapter {
387
388
  * column writes that genuinely pass a JS array as a JSON value).
388
389
  */
389
390
  async function executeQuery(sql: SqlInstance, params: { text: string; values: unknown[] }): Promise<Record<string, unknown>[]> {
391
+ // Defence-in-depth: if any value is a runtime PgArray that slipped through
392
+ // (e.g. a caller bypassed `client.ts`'s formatArrayParam unwrap), convert
393
+ // it to the PG array literal string that bun:sql actually needs. The
394
+ // standard ORM path has already done this conversion via `formatArrayParam`,
395
+ // so the loop is a near-zero-cost guard for the normal case.
396
+ // Bug 3 — see .ai/bug-report-2026-05-24.md.
397
+ let values: unknown[] = params.values;
398
+ for (let i = 0; i < params.values.length; i++) {
399
+ if (params.values[i] instanceof PgArray) {
400
+ if (values === params.values) values = params.values.slice();
401
+ values[i] = toPgArrayLiteral((params.values[i] as PgArray).values);
402
+ }
403
+ }
390
404
  if (USE_PREPARED) {
391
405
  const strings = getOrCreateTemplate({ text: params.text });
392
- const result = await sql(strings, ...params.values);
406
+ const result = await sql(strings, ...values);
393
407
  return result as Record<string, unknown>[];
394
408
  }
395
- const result = await sql.unsafe(params.text, params.values);
409
+ const result = await sql.unsafe(params.text, values);
396
410
  return result as Record<string, unknown>[];
397
411
  }
398
412