@prisma/adapter-better-sqlite3 6.15.0-dev.3 → 6.15.0-dev.30

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
@@ -366,9 +366,9 @@ var UnexpectedTypeError = class extends Error {
366
366
  }
367
367
  };
368
368
  function mapRow(row, columnTypes) {
369
- const result = Array.from(row);
370
- for (let i = 0; i < result.length; i++) {
371
- const value = result[i];
369
+ const result = [];
370
+ for (let i = 0; i < row.length; i++) {
371
+ const value = row[i];
372
372
  if (value instanceof ArrayBuffer || value instanceof Buffer) {
373
373
  result[i] = Array.from(new Uint8Array(value));
374
374
  continue;
@@ -385,29 +385,42 @@ function mapRow(row, columnTypes) {
385
385
  result[i] = value.toString();
386
386
  continue;
387
387
  }
388
+ result[i] = value;
388
389
  }
389
390
  return result;
390
391
  }
391
- function mapQueryArgs(args, argTypes) {
392
- return args.map((arg, i) => {
393
- const argType = argTypes[i];
394
- if (argType === "Int32") {
395
- return Number.parseInt(arg);
396
- }
397
- if (argType === "Float" || argType === "Double") {
398
- return Number.parseFloat(arg);
399
- }
400
- if (typeof arg === "boolean") {
401
- return arg ? 1 : 0;
402
- }
403
- if (arg instanceof Date) {
404
- return arg.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "");
405
- }
406
- if (arg instanceof Uint8Array) {
407
- return Buffer.from(arg);
408
- }
409
- return arg;
410
- });
392
+ function mapArg(arg, argType) {
393
+ if (arg === null) {
394
+ return null;
395
+ }
396
+ if (typeof arg === "string" && argType.scalarType === "int") {
397
+ return Number.parseInt(arg);
398
+ }
399
+ if (typeof arg === "string" && argType.scalarType === "float") {
400
+ return Number.parseFloat(arg);
401
+ }
402
+ if (typeof arg === "string" && argType.scalarType === "decimal") {
403
+ return Number.parseFloat(arg);
404
+ }
405
+ if (typeof arg === "string" && argType.scalarType === "bigint") {
406
+ return BigInt(arg);
407
+ }
408
+ if (typeof arg === "boolean") {
409
+ return arg ? 1 : 0;
410
+ }
411
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
412
+ arg = new Date(arg);
413
+ }
414
+ if (arg instanceof Date) {
415
+ return arg.toISOString().replace("Z", "+00:00");
416
+ }
417
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
418
+ return Buffer.from(arg, "base64");
419
+ }
420
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
421
+ return Buffer.from(arg);
422
+ }
423
+ return arg;
411
424
  }
412
425
 
413
426
  // src/errors.ts
@@ -512,7 +525,8 @@ var BetterSQLite3Queryable = class {
512
525
  */
513
526
  executeIO(query) {
514
527
  try {
515
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
528
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
529
+ const stmt = this.client.prepare(query.sql).bind(args);
516
530
  const result = stmt.run();
517
531
  return Promise.resolve(result);
518
532
  } catch (e) {
@@ -526,7 +540,8 @@ var BetterSQLite3Queryable = class {
526
540
  */
527
541
  performIO(query) {
528
542
  try {
529
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
543
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
544
+ const stmt = this.client.prepare(query.sql).bind(args);
530
545
  if (!stmt.reader) {
531
546
  stmt.run();
532
547
  return Promise.resolve({
package/dist/index.mjs CHANGED
@@ -330,9 +330,9 @@ var UnexpectedTypeError = class extends Error {
330
330
  }
331
331
  };
332
332
  function mapRow(row, columnTypes) {
333
- const result = Array.from(row);
334
- for (let i = 0; i < result.length; i++) {
335
- const value = result[i];
333
+ const result = [];
334
+ for (let i = 0; i < row.length; i++) {
335
+ const value = row[i];
336
336
  if (value instanceof ArrayBuffer || value instanceof Buffer) {
337
337
  result[i] = Array.from(new Uint8Array(value));
338
338
  continue;
@@ -349,29 +349,42 @@ function mapRow(row, columnTypes) {
349
349
  result[i] = value.toString();
350
350
  continue;
351
351
  }
352
+ result[i] = value;
352
353
  }
353
354
  return result;
354
355
  }
355
- function mapQueryArgs(args, argTypes) {
356
- return args.map((arg, i) => {
357
- const argType = argTypes[i];
358
- if (argType === "Int32") {
359
- return Number.parseInt(arg);
360
- }
361
- if (argType === "Float" || argType === "Double") {
362
- return Number.parseFloat(arg);
363
- }
364
- if (typeof arg === "boolean") {
365
- return arg ? 1 : 0;
366
- }
367
- if (arg instanceof Date) {
368
- return arg.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "");
369
- }
370
- if (arg instanceof Uint8Array) {
371
- return Buffer.from(arg);
372
- }
373
- return arg;
374
- });
356
+ function mapArg(arg, argType) {
357
+ if (arg === null) {
358
+ return null;
359
+ }
360
+ if (typeof arg === "string" && argType.scalarType === "int") {
361
+ return Number.parseInt(arg);
362
+ }
363
+ if (typeof arg === "string" && argType.scalarType === "float") {
364
+ return Number.parseFloat(arg);
365
+ }
366
+ if (typeof arg === "string" && argType.scalarType === "decimal") {
367
+ return Number.parseFloat(arg);
368
+ }
369
+ if (typeof arg === "string" && argType.scalarType === "bigint") {
370
+ return BigInt(arg);
371
+ }
372
+ if (typeof arg === "boolean") {
373
+ return arg ? 1 : 0;
374
+ }
375
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
376
+ arg = new Date(arg);
377
+ }
378
+ if (arg instanceof Date) {
379
+ return arg.toISOString().replace("Z", "+00:00");
380
+ }
381
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
382
+ return Buffer.from(arg, "base64");
383
+ }
384
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
385
+ return Buffer.from(arg);
386
+ }
387
+ return arg;
375
388
  }
376
389
 
377
390
  // src/errors.ts
@@ -476,7 +489,8 @@ var BetterSQLite3Queryable = class {
476
489
  */
477
490
  executeIO(query) {
478
491
  try {
479
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
492
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
493
+ const stmt = this.client.prepare(query.sql).bind(args);
480
494
  const result = stmt.run();
481
495
  return Promise.resolve(result);
482
496
  } catch (e) {
@@ -490,7 +504,8 @@ var BetterSQLite3Queryable = class {
490
504
  */
491
505
  performIO(query) {
492
506
  try {
493
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
507
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
508
+ const stmt = this.client.prepare(query.sql).bind(args);
494
509
  if (!stmt.reader) {
495
510
  stmt.run();
496
511
  return Promise.resolve({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-better-sqlite3",
3
- "version": "6.15.0-dev.3",
3
+ "version": "6.15.0-dev.30",
4
4
  "description": "Prisma's driver adapter for better-sqlite3, a fast SQLite3 driver for JavaScript runtimes",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,7 +32,7 @@
32
32
  "sideEffects": false,
33
33
  "dependencies": {
34
34
  "better-sqlite3": "^11.9.0",
35
- "@prisma/driver-adapter-utils": "6.15.0-dev.3"
35
+ "@prisma/driver-adapter-utils": "6.15.0-dev.30"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/better-sqlite3": "7.6.12",