@prisma/adapter-neon 6.15.0-dev.2 → 6.15.0-dev.4

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/dist/index.js CHANGED
@@ -354,20 +354,35 @@ var customParsers = {
354
354
  [ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
355
355
  [ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
356
356
  };
357
- function fixArrayBufferValues(values) {
358
- for (let i = 0; i < values.length; i++) {
359
- const list = values[i];
360
- if (!Array.isArray(list)) {
361
- continue;
362
- }
363
- for (let j = 0; j < list.length; j++) {
364
- const listItem = list[j];
365
- if (ArrayBuffer.isView(listItem)) {
366
- list[j] = Buffer.from(listItem.buffer, listItem.byteOffset, listItem.byteLength);
367
- }
357
+ function mapArg(arg, argType) {
358
+ if (arg === null) {
359
+ return null;
360
+ }
361
+ if (Array.isArray(arg) && argType.arity === "list") {
362
+ return arg.map((value) => mapArg(value, argType));
363
+ }
364
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
365
+ arg = new Date(arg);
366
+ }
367
+ if (arg instanceof Date) {
368
+ switch (argType.dbType) {
369
+ case "TIME":
370
+ case "TIMETZ":
371
+ return arg.toISOString().split("T")[1];
372
+ default:
373
+ return arg.toISOString();
368
374
  }
369
375
  }
370
- return values;
376
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
377
+ return Buffer.from(arg, "base64");
378
+ }
379
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
380
+ return Buffer.from(arg);
381
+ }
382
+ if (ArrayBuffer.isView(arg)) {
383
+ return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
384
+ }
385
+ return arg;
371
386
  }
372
387
 
373
388
  // src/errors.ts
@@ -522,12 +537,11 @@ var NeonWsQueryable = class extends NeonQueryable {
522
537
  this.client = client;
523
538
  }
524
539
  async performIO(query) {
525
- const { sql, args: values } = query;
540
+ const { sql, args } = query;
526
541
  try {
527
542
  const result = await this.client.query(
528
543
  {
529
544
  text: sql,
530
- values: fixArrayBufferValues(values),
531
545
  rowMode: "array",
532
546
  types: {
533
547
  // This is the error expected:
@@ -550,7 +564,7 @@ var NeonWsQueryable = class extends NeonQueryable {
550
564
  }
551
565
  }
552
566
  },
553
- fixArrayBufferValues(values)
567
+ args.map((arg, i) => mapArg(arg, query.argTypes[i]))
554
568
  );
555
569
  return result;
556
570
  } catch (e) {
package/dist/index.mjs CHANGED
@@ -317,20 +317,35 @@ var customParsers = {
317
317
  [ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
318
318
  [ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
319
319
  };
320
- function fixArrayBufferValues(values) {
321
- for (let i = 0; i < values.length; i++) {
322
- const list = values[i];
323
- if (!Array.isArray(list)) {
324
- continue;
325
- }
326
- for (let j = 0; j < list.length; j++) {
327
- const listItem = list[j];
328
- if (ArrayBuffer.isView(listItem)) {
329
- list[j] = Buffer.from(listItem.buffer, listItem.byteOffset, listItem.byteLength);
330
- }
320
+ function mapArg(arg, argType) {
321
+ if (arg === null) {
322
+ return null;
323
+ }
324
+ if (Array.isArray(arg) && argType.arity === "list") {
325
+ return arg.map((value) => mapArg(value, argType));
326
+ }
327
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
328
+ arg = new Date(arg);
329
+ }
330
+ if (arg instanceof Date) {
331
+ switch (argType.dbType) {
332
+ case "TIME":
333
+ case "TIMETZ":
334
+ return arg.toISOString().split("T")[1];
335
+ default:
336
+ return arg.toISOString();
331
337
  }
332
338
  }
333
- return values;
339
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
340
+ return Buffer.from(arg, "base64");
341
+ }
342
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
343
+ return Buffer.from(arg);
344
+ }
345
+ if (ArrayBuffer.isView(arg)) {
346
+ return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
347
+ }
348
+ return arg;
334
349
  }
335
350
 
336
351
  // src/errors.ts
@@ -485,12 +500,11 @@ var NeonWsQueryable = class extends NeonQueryable {
485
500
  this.client = client;
486
501
  }
487
502
  async performIO(query) {
488
- const { sql, args: values } = query;
503
+ const { sql, args } = query;
489
504
  try {
490
505
  const result = await this.client.query(
491
506
  {
492
507
  text: sql,
493
- values: fixArrayBufferValues(values),
494
508
  rowMode: "array",
495
509
  types: {
496
510
  // This is the error expected:
@@ -513,7 +527,7 @@ var NeonWsQueryable = class extends NeonQueryable {
513
527
  }
514
528
  }
515
529
  },
516
- fixArrayBufferValues(values)
530
+ args.map((arg, i) => mapArg(arg, query.argTypes[i]))
517
531
  );
518
532
  return result;
519
533
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-neon",
3
- "version": "6.15.0-dev.2",
3
+ "version": "6.15.0-dev.4",
4
4
  "description": "Prisma's driver adapter for \"@neondatabase/serverless\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "postgres-array": "3.0.4",
35
35
  "@neondatabase/serverless": ">0.6.0 <2",
36
- "@prisma/driver-adapter-utils": "6.15.0-dev.2"
36
+ "@prisma/driver-adapter-utils": "6.15.0-dev.4"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@swc/core": "1.11.5",