@prisma/adapter-neon 8.1.0-dev.11 → 8.1.0-dev.12
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 +39 -4
- package/dist/index.mjs +39 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -608,15 +608,50 @@ var NeonTransaction = class extends NeonWsQueryable {
|
|
|
608
608
|
this.options = options;
|
|
609
609
|
this.cleanup = cleanup;
|
|
610
610
|
}
|
|
611
|
+
closed = false;
|
|
612
|
+
runningStatements = 0;
|
|
613
|
+
async performIO(query) {
|
|
614
|
+
if (this.closed) {
|
|
615
|
+
throw new import_driver_adapter_utils2.DriverAdapterError({
|
|
616
|
+
kind: "TransactionAlreadyClosed",
|
|
617
|
+
cause: "The transaction has already been committed or rolled back"
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
this.runningStatements++;
|
|
621
|
+
try {
|
|
622
|
+
return await super.performIO(query);
|
|
623
|
+
} finally {
|
|
624
|
+
this.runningStatements--;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Closes the transaction at most once. Once the pool has lent the client to
|
|
629
|
+
* a new owner, a second `release()` would corrupt the pool's bookkeeping, so
|
|
630
|
+
* it is skipped. A client with a statement still running is released with an
|
|
631
|
+
* error so the pool destroys it instead of lending out a busy connection.
|
|
632
|
+
*/
|
|
633
|
+
close() {
|
|
634
|
+
if (this.closed) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
this.closed = true;
|
|
638
|
+
try {
|
|
639
|
+
this.cleanup?.();
|
|
640
|
+
} finally {
|
|
641
|
+
if (this.runningStatements > 0) {
|
|
642
|
+
this.client.release(new Error("Transaction closed with a statement still running"));
|
|
643
|
+
} else {
|
|
644
|
+
this.client.release();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
611
648
|
async commit() {
|
|
612
649
|
debug(`[js::commit]`);
|
|
613
|
-
this.
|
|
614
|
-
this.client.release();
|
|
650
|
+
this.close();
|
|
615
651
|
}
|
|
616
652
|
async rollback() {
|
|
617
653
|
debug(`[js::rollback]`);
|
|
618
|
-
this.
|
|
619
|
-
this.client.release();
|
|
654
|
+
this.close();
|
|
620
655
|
}
|
|
621
656
|
async createSavepoint(name2) {
|
|
622
657
|
await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
|
package/dist/index.mjs
CHANGED
|
@@ -571,15 +571,50 @@ var NeonTransaction = class extends NeonWsQueryable {
|
|
|
571
571
|
this.options = options;
|
|
572
572
|
this.cleanup = cleanup;
|
|
573
573
|
}
|
|
574
|
+
closed = false;
|
|
575
|
+
runningStatements = 0;
|
|
576
|
+
async performIO(query) {
|
|
577
|
+
if (this.closed) {
|
|
578
|
+
throw new DriverAdapterError({
|
|
579
|
+
kind: "TransactionAlreadyClosed",
|
|
580
|
+
cause: "The transaction has already been committed or rolled back"
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
this.runningStatements++;
|
|
584
|
+
try {
|
|
585
|
+
return await super.performIO(query);
|
|
586
|
+
} finally {
|
|
587
|
+
this.runningStatements--;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Closes the transaction at most once. Once the pool has lent the client to
|
|
592
|
+
* a new owner, a second `release()` would corrupt the pool's bookkeeping, so
|
|
593
|
+
* it is skipped. A client with a statement still running is released with an
|
|
594
|
+
* error so the pool destroys it instead of lending out a busy connection.
|
|
595
|
+
*/
|
|
596
|
+
close() {
|
|
597
|
+
if (this.closed) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
this.closed = true;
|
|
601
|
+
try {
|
|
602
|
+
this.cleanup?.();
|
|
603
|
+
} finally {
|
|
604
|
+
if (this.runningStatements > 0) {
|
|
605
|
+
this.client.release(new Error("Transaction closed with a statement still running"));
|
|
606
|
+
} else {
|
|
607
|
+
this.client.release();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
574
611
|
async commit() {
|
|
575
612
|
debug(`[js::commit]`);
|
|
576
|
-
this.
|
|
577
|
-
this.client.release();
|
|
613
|
+
this.close();
|
|
578
614
|
}
|
|
579
615
|
async rollback() {
|
|
580
616
|
debug(`[js::rollback]`);
|
|
581
|
-
this.
|
|
582
|
-
this.client.release();
|
|
617
|
+
this.close();
|
|
583
618
|
}
|
|
584
619
|
async createSavepoint(name2) {
|
|
585
620
|
await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-neon",
|
|
3
|
-
"version": "8.1.0-dev.
|
|
3
|
+
"version": "8.1.0-dev.12",
|
|
4
4
|
"description": "Prisma's driver adapter for \"@neondatabase/serverless\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"postgres-array": "3.0.4",
|
|
35
35
|
"@neondatabase/serverless": ">0.6.0 <2",
|
|
36
|
-
"@prisma/driver-adapter-utils": "8.1.0-dev.
|
|
36
|
+
"@prisma/driver-adapter-utils": "8.1.0-dev.12"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@prisma/debug": "8.1.0-dev.
|
|
39
|
+
"@prisma/debug": "8.1.0-dev.12"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "DEV=true tsx helpers/build.ts",
|