diff --git a/docs/driver.rst b/docs/driver.rst index 0dc62a325..9b678a49a 100644 --- a/docs/driver.rst +++ b/docs/driver.rst @@ -92,7 +92,7 @@ value specified below is the *default value* for that setting. }, }) .withTransactionOptions({ - isolation: IsolationLevel.Serializable, // only supported value + isolation: IsolationLevel.Serializable, // or .RepeatableRead if readonly deferrable: false, readonly: false, }); diff --git a/packages/driver/src/options.ts b/packages/driver/src/options.ts index 4ac17adbb..ab7addd4d 100644 --- a/packages/driver/src/options.ts +++ b/packages/driver/src/options.ts @@ -14,6 +14,7 @@ export function defaultBackoff(attempt: number): number { export enum IsolationLevel { Serializable = "SERIALIZABLE", + RepeatableRead = "REPEATABLE READ", } export enum RetryCondition { diff --git a/packages/driver/test/transaction.test.ts b/packages/driver/test/transaction.test.ts index d1e826cc8..0118bb0ce 100644 --- a/packages/driver/test/transaction.test.ts +++ b/packages/driver/test/transaction.test.ts @@ -21,7 +21,7 @@ import { type Client } from "../src/index.node"; import { IsolationLevel, TransactionOptions } from "../src/options"; import { sleep } from "../src/utils"; import Event from "../src/primitives/event"; -import { getClient } from "./testbase"; +import { getClient, getEdgeDBVersion } from "./testbase"; const typename = "TransactionTest"; @@ -82,17 +82,24 @@ test("transaction: regular 01", async () => { }); }, 10_000); +const levels = [ + undefined, + IsolationLevel.Serializable, + ...(getEdgeDBVersion().major >= 6 ? [IsolationLevel.RepeatableRead] : []), +]; + function* all_options(): Generator< [IsolationLevel | undefined, boolean | undefined, boolean | undefined], void, void > { - const levels = [undefined, IsolationLevel.Serializable]; const booleans = [undefined, true, false]; for (const isolation of levels) { for (const readonly of booleans) { for (const deferred of booleans) { - yield [isolation, readonly, deferred]; + if (isolation != IsolationLevel.RepeatableRead || readonly) { + yield [isolation, readonly, deferred]; + } } } }