There was an error while loading. Please reload this page.
2 parents 22e513b + 7a9413e commit dad7b32Copy full SHA for dad7b32
1 file changed
src/lib/postgres.ts
@@ -10,6 +10,7 @@ import { Future } from '@/lib/Future';
10
11
class PostgresTransaction {
12
public closed: boolean = false;
13
+ private started: boolean = false;
14
15
constructor(private connection: PoolClient) {}
16
@@ -60,6 +61,11 @@ class PostgresTransaction {
60
61
query: string | QueryConfig<string[]>,
62
values?: string[] | undefined,
63
): Promise<QueryResult<any>> {
64
+ if (!this.started) {
65
+ await this.connection.query('BEGIN ISOLATION LEVEL SERIALIZABLE');
66
+ this.started = true;
67
+ }
68
+
69
if (this.closed) {
70
throw new Error('Querying a closed connection');
71
}
0 commit comments