fix(housekeeping): isolate poll question mutations
This commit is contained in:
1 parent
de7cc42ddf
commit
f64b4d67b4
2 files changed
+25
-15
No files matched your search
@@ -101,24 +101,34 @@ describe("Content production mutation adapter", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("uses read committed isolation only for poll mutations", async () => {
|
||||
const pollDeps = dependencies();
|
||||
await pollDeps.adapter.execute(
|
||||
"poll.change",
|
||||
{ action: "delete", id: 7 },
|
||||
mutationContext,
|
||||
);
|
||||
expect(pollDeps.transaction).toHaveBeenCalledWith(expect.any(Function), {
|
||||
isolationLevel: "read committed",
|
||||
});
|
||||
it.each(["poll.change", "poll-question.change"] as const)(
|
||||
"uses read committed isolation for %s",
|
||||
async (operation) => {
|
||||
const deps = dependencies();
|
||||
await deps.adapter.execute(
|
||||
operation,
|
||||
{ action: "update", id: 7 },
|
||||
mutationContext,
|
||||
);
|
||||
expect(deps.transaction).toHaveBeenCalledWith(expect.any(Function), {
|
||||
isolationLevel: "read committed",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const articleDeps = dependencies();
|
||||
await articleDeps.adapter.execute(
|
||||
"article.change",
|
||||
it.each(
|
||||
CONTENT_DATABASE_OPERATIONS.filter(
|
||||
(operation) =>
|
||||
operation !== "poll.change" && operation !== "poll-question.change",
|
||||
),
|
||||
)("keeps configured server isolation for unrelated %s", async (operation) => {
|
||||
const deps = dependencies();
|
||||
await deps.adapter.execute(
|
||||
operation,
|
||||
{ action: "update", id: 7 },
|
||||
mutationContext,
|
||||
);
|
||||
expect(articleDeps.transaction).toHaveBeenCalledWith(
|
||||
expect(deps.transaction).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
undefined,
|
||||
);
|
||||
|
||||
@@ -132,7 +132,7 @@ export function createContentProductionMutationAdapter(
|
||||
async execute(operation, input, context) {
|
||||
if (includesOperation(CONTENT_DATABASE_OPERATIONS, operation)) {
|
||||
const transactionOptions =
|
||||
operation === "poll.change"
|
||||
operation === "poll.change" || operation === "poll-question.change"
|
||||
? ({ isolationLevel: "read committed" } as const)
|
||||
: undefined;
|
||||
return dependencies.transaction(async (transaction) => {
|
||||
|
||||
Reference in new issue
Block a user