@prisma/adapter-better-sqlite3 6.15.0-dev.3 → 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
@@ -388,26 +388,38 @@ function mapRow(row, columnTypes) {
388
388
  }
389
389
  return result;
390
390
  }
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
- });
391
+ function mapArg(arg, argType) {
392
+ if (arg === null) {
393
+ return null;
394
+ }
395
+ if (typeof arg === "string" && argType.scalarType === "int") {
396
+ return Number.parseInt(arg);
397
+ }
398
+ if (typeof arg === "string" && argType.scalarType === "float") {
399
+ return Number.parseFloat(arg);
400
+ }
401
+ if (typeof arg === "string" && argType.scalarType === "decimal") {
402
+ return Number.parseFloat(arg);
403
+ }
404
+ if (typeof arg === "string" && argType.scalarType === "bigint") {
405
+ return BigInt(arg);
406
+ }
407
+ if (typeof arg === "boolean") {
408
+ return arg ? 1 : 0;
409
+ }
410
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
411
+ arg = new Date(arg);
412
+ }
413
+ if (arg instanceof Date) {
414
+ return arg.toISOString().replace("Z", "+00:00");
415
+ }
416
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
417
+ return Buffer.from(arg, "base64");
418
+ }
419
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
420
+ return Buffer.from(arg);
421
+ }
422
+ return arg;
411
423
  }
412
424
 
413
425
  // src/errors.ts
@@ -512,7 +524,8 @@ var BetterSQLite3Queryable = class {
512
524
  */
513
525
  executeIO(query) {
514
526
  try {
515
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
527
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
528
+ const stmt = this.client.prepare(query.sql).bind(args);
516
529
  const result = stmt.run();
517
530
  return Promise.resolve(result);
518
531
  } catch (e) {
@@ -526,7 +539,8 @@ var BetterSQLite3Queryable = class {
526
539
  */
527
540
  performIO(query) {
528
541
  try {
529
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
542
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
543
+ const stmt = this.client.prepare(query.sql).bind(args);
530
544
  if (!stmt.reader) {
531
545
  stmt.run();
532
546
  return Promise.resolve({
package/dist/index.mjs CHANGED
@@ -352,26 +352,38 @@ function mapRow(row, columnTypes) {
352
352
  }
353
353
  return result;
354
354
  }
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
- });
355
+ function mapArg(arg, argType) {
356
+ if (arg === null) {
357
+ return null;
358
+ }
359
+ if (typeof arg === "string" && argType.scalarType === "int") {
360
+ return Number.parseInt(arg);
361
+ }
362
+ if (typeof arg === "string" && argType.scalarType === "float") {
363
+ return Number.parseFloat(arg);
364
+ }
365
+ if (typeof arg === "string" && argType.scalarType === "decimal") {
366
+ return Number.parseFloat(arg);
367
+ }
368
+ if (typeof arg === "string" && argType.scalarType === "bigint") {
369
+ return BigInt(arg);
370
+ }
371
+ if (typeof arg === "boolean") {
372
+ return arg ? 1 : 0;
373
+ }
374
+ if (typeof arg === "string" && argType.scalarType === "datetime") {
375
+ arg = new Date(arg);
376
+ }
377
+ if (arg instanceof Date) {
378
+ return arg.toISOString().replace("Z", "+00:00");
379
+ }
380
+ if (typeof arg === "string" && argType.scalarType === "bytes") {
381
+ return Buffer.from(arg, "base64");
382
+ }
383
+ if (Array.isArray(arg) && argType.scalarType === "bytes") {
384
+ return Buffer.from(arg);
385
+ }
386
+ return arg;
375
387
  }
376
388
 
377
389
  // src/errors.ts
@@ -476,7 +488,8 @@ var BetterSQLite3Queryable = class {
476
488
  */
477
489
  executeIO(query) {
478
490
  try {
479
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
491
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
492
+ const stmt = this.client.prepare(query.sql).bind(args);
480
493
  const result = stmt.run();
481
494
  return Promise.resolve(result);
482
495
  } catch (e) {
@@ -490,7 +503,8 @@ var BetterSQLite3Queryable = class {
490
503
  */
491
504
  performIO(query) {
492
505
  try {
493
- const stmt = this.client.prepare(query.sql).bind(mapQueryArgs(query.args, query.argTypes));
506
+ const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i]));
507
+ const stmt = this.client.prepare(query.sql).bind(args);
494
508
  if (!stmt.reader) {
495
509
  stmt.run();
496
510
  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.4",
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.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/better-sqlite3": "7.6.12",