@prisma/adapter-better-sqlite3 7.11.0-dev.1 → 7.11.0-dev.11
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 +19 -12
- package/dist/index.mjs +19 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -517,6 +517,7 @@ var BetterSQLite3Queryable = class {
|
|
|
517
517
|
}
|
|
518
518
|
provider = "sqlite";
|
|
519
519
|
adapterName = name;
|
|
520
|
+
lock = new Mutex();
|
|
520
521
|
/**
|
|
521
522
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
522
523
|
*/
|
|
@@ -547,14 +548,16 @@ var BetterSQLite3Queryable = class {
|
|
|
547
548
|
* Should the query fail due to a connection error, the connection is
|
|
548
549
|
* marked as unhealthy.
|
|
549
550
|
*/
|
|
550
|
-
executeIO(query) {
|
|
551
|
+
async executeIO(query) {
|
|
552
|
+
const release = await this.lock.acquire();
|
|
551
553
|
try {
|
|
552
554
|
const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions));
|
|
553
555
|
const stmt = this.client.prepare(query.sql).bind(args);
|
|
554
|
-
|
|
555
|
-
return Promise.resolve(result);
|
|
556
|
+
return stmt.run();
|
|
556
557
|
} catch (e) {
|
|
557
558
|
this.onError(e);
|
|
559
|
+
} finally {
|
|
560
|
+
release();
|
|
558
561
|
}
|
|
559
562
|
}
|
|
560
563
|
/**
|
|
@@ -562,27 +565,29 @@ var BetterSQLite3Queryable = class {
|
|
|
562
565
|
* Should the query fail due to a connection error, the connection is
|
|
563
566
|
* marked as unhealthy.
|
|
564
567
|
*/
|
|
565
|
-
performIO(query) {
|
|
568
|
+
async performIO(query) {
|
|
569
|
+
const release = await this.lock.acquire();
|
|
566
570
|
try {
|
|
567
571
|
const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions));
|
|
568
572
|
const stmt = this.client.prepare(query.sql).bind(args);
|
|
569
573
|
if (!stmt.reader) {
|
|
570
574
|
stmt.run();
|
|
571
|
-
return
|
|
575
|
+
return {
|
|
572
576
|
columnNames: [],
|
|
573
577
|
declaredTypes: [],
|
|
574
578
|
values: []
|
|
575
|
-
}
|
|
579
|
+
};
|
|
576
580
|
}
|
|
577
581
|
const columns = stmt.columns();
|
|
578
|
-
|
|
582
|
+
return {
|
|
579
583
|
declaredTypes: columns.map((column) => column.type),
|
|
580
584
|
columnNames: columns.map((column) => column.name),
|
|
581
585
|
values: stmt.raw().all()
|
|
582
586
|
};
|
|
583
|
-
return Promise.resolve(resultSet);
|
|
584
587
|
} catch (e) {
|
|
585
588
|
this.onError(e);
|
|
589
|
+
} finally {
|
|
590
|
+
release();
|
|
586
591
|
}
|
|
587
592
|
}
|
|
588
593
|
onError(error) {
|
|
@@ -618,7 +623,6 @@ var BetterSQLite3Transaction = class extends BetterSQLite3Queryable {
|
|
|
618
623
|
}
|
|
619
624
|
};
|
|
620
625
|
var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
621
|
-
#mutex = new Mutex();
|
|
622
626
|
#maxBindValues;
|
|
623
627
|
constructor(client, adapterOptions) {
|
|
624
628
|
super(client, adapterOptions);
|
|
@@ -630,13 +634,15 @@ var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
|
630
634
|
supportsRelationJoins: false
|
|
631
635
|
};
|
|
632
636
|
}
|
|
633
|
-
executeScript(script) {
|
|
637
|
+
async executeScript(script) {
|
|
638
|
+
const release = await this.lock.acquire();
|
|
634
639
|
try {
|
|
635
640
|
this.client.exec(script);
|
|
636
641
|
} catch (e) {
|
|
637
642
|
this.onError(e);
|
|
643
|
+
} finally {
|
|
644
|
+
release();
|
|
638
645
|
}
|
|
639
|
-
return Promise.resolve();
|
|
640
646
|
}
|
|
641
647
|
async startTransaction(isolationLevel) {
|
|
642
648
|
if (isolationLevel && isolationLevel !== "SERIALIZABLE") {
|
|
@@ -650,11 +656,12 @@ var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
|
650
656
|
};
|
|
651
657
|
const tag = "[js::startTransaction]";
|
|
652
658
|
debug2("%s options: %O", tag, options);
|
|
659
|
+
const release = await this.lock.acquire();
|
|
653
660
|
try {
|
|
654
|
-
const release = await this.#mutex.acquire();
|
|
655
661
|
this.client.prepare("BEGIN").run();
|
|
656
662
|
return new BetterSQLite3Transaction(this.client, options, this.adapterOptions, release);
|
|
657
663
|
} catch (e) {
|
|
664
|
+
release();
|
|
658
665
|
this.onError(e);
|
|
659
666
|
}
|
|
660
667
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -481,6 +481,7 @@ var BetterSQLite3Queryable = class {
|
|
|
481
481
|
}
|
|
482
482
|
provider = "sqlite";
|
|
483
483
|
adapterName = name;
|
|
484
|
+
lock = new Mutex();
|
|
484
485
|
/**
|
|
485
486
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
486
487
|
*/
|
|
@@ -511,14 +512,16 @@ var BetterSQLite3Queryable = class {
|
|
|
511
512
|
* Should the query fail due to a connection error, the connection is
|
|
512
513
|
* marked as unhealthy.
|
|
513
514
|
*/
|
|
514
|
-
executeIO(query) {
|
|
515
|
+
async executeIO(query) {
|
|
516
|
+
const release = await this.lock.acquire();
|
|
515
517
|
try {
|
|
516
518
|
const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions));
|
|
517
519
|
const stmt = this.client.prepare(query.sql).bind(args);
|
|
518
|
-
|
|
519
|
-
return Promise.resolve(result);
|
|
520
|
+
return stmt.run();
|
|
520
521
|
} catch (e) {
|
|
521
522
|
this.onError(e);
|
|
523
|
+
} finally {
|
|
524
|
+
release();
|
|
522
525
|
}
|
|
523
526
|
}
|
|
524
527
|
/**
|
|
@@ -526,27 +529,29 @@ var BetterSQLite3Queryable = class {
|
|
|
526
529
|
* Should the query fail due to a connection error, the connection is
|
|
527
530
|
* marked as unhealthy.
|
|
528
531
|
*/
|
|
529
|
-
performIO(query) {
|
|
532
|
+
async performIO(query) {
|
|
533
|
+
const release = await this.lock.acquire();
|
|
530
534
|
try {
|
|
531
535
|
const args = query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions));
|
|
532
536
|
const stmt = this.client.prepare(query.sql).bind(args);
|
|
533
537
|
if (!stmt.reader) {
|
|
534
538
|
stmt.run();
|
|
535
|
-
return
|
|
539
|
+
return {
|
|
536
540
|
columnNames: [],
|
|
537
541
|
declaredTypes: [],
|
|
538
542
|
values: []
|
|
539
|
-
}
|
|
543
|
+
};
|
|
540
544
|
}
|
|
541
545
|
const columns = stmt.columns();
|
|
542
|
-
|
|
546
|
+
return {
|
|
543
547
|
declaredTypes: columns.map((column) => column.type),
|
|
544
548
|
columnNames: columns.map((column) => column.name),
|
|
545
549
|
values: stmt.raw().all()
|
|
546
550
|
};
|
|
547
|
-
return Promise.resolve(resultSet);
|
|
548
551
|
} catch (e) {
|
|
549
552
|
this.onError(e);
|
|
553
|
+
} finally {
|
|
554
|
+
release();
|
|
550
555
|
}
|
|
551
556
|
}
|
|
552
557
|
onError(error) {
|
|
@@ -582,7 +587,6 @@ var BetterSQLite3Transaction = class extends BetterSQLite3Queryable {
|
|
|
582
587
|
}
|
|
583
588
|
};
|
|
584
589
|
var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
585
|
-
#mutex = new Mutex();
|
|
586
590
|
#maxBindValues;
|
|
587
591
|
constructor(client, adapterOptions) {
|
|
588
592
|
super(client, adapterOptions);
|
|
@@ -594,13 +598,15 @@ var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
|
594
598
|
supportsRelationJoins: false
|
|
595
599
|
};
|
|
596
600
|
}
|
|
597
|
-
executeScript(script) {
|
|
601
|
+
async executeScript(script) {
|
|
602
|
+
const release = await this.lock.acquire();
|
|
598
603
|
try {
|
|
599
604
|
this.client.exec(script);
|
|
600
605
|
} catch (e) {
|
|
601
606
|
this.onError(e);
|
|
607
|
+
} finally {
|
|
608
|
+
release();
|
|
602
609
|
}
|
|
603
|
-
return Promise.resolve();
|
|
604
610
|
}
|
|
605
611
|
async startTransaction(isolationLevel) {
|
|
606
612
|
if (isolationLevel && isolationLevel !== "SERIALIZABLE") {
|
|
@@ -614,11 +620,12 @@ var PrismaBetterSqlite3Adapter = class extends BetterSQLite3Queryable {
|
|
|
614
620
|
};
|
|
615
621
|
const tag = "[js::startTransaction]";
|
|
616
622
|
debug2("%s options: %O", tag, options);
|
|
623
|
+
const release = await this.lock.acquire();
|
|
617
624
|
try {
|
|
618
|
-
const release = await this.#mutex.acquire();
|
|
619
625
|
this.client.prepare("BEGIN").run();
|
|
620
626
|
return new BetterSQLite3Transaction(this.client, options, this.adapterOptions, release);
|
|
621
627
|
} catch (e) {
|
|
628
|
+
release();
|
|
622
629
|
this.onError(e);
|
|
623
630
|
}
|
|
624
631
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-better-sqlite3",
|
|
3
|
-
"version": "7.11.0-dev.
|
|
3
|
+
"version": "7.11.0-dev.11",
|
|
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": "^12.6.0",
|
|
35
|
-
"@prisma/driver-adapter-utils": "7.11.0-dev.
|
|
35
|
+
"@prisma/driver-adapter-utils": "7.11.0-dev.11"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/better-sqlite3": "7.6.12",
|