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 () => {
|
it.each(["poll.change", "poll-question.change"] as const)(
|
||||||
const pollDeps = dependencies();
|
"uses read committed isolation for %s",
|
||||||
await pollDeps.adapter.execute(
|
async (operation) => {
|
||||||
"poll.change",
|
const deps = dependencies();
|
||||||
{ action: "delete", id: 7 },
|
await deps.adapter.execute(
|
||||||
mutationContext,
|
operation,
|
||||||
);
|
{ action: "update", id: 7 },
|
||||||
expect(pollDeps.transaction).toHaveBeenCalledWith(expect.any(Function), {
|
mutationContext,
|
||||||
isolationLevel: "read committed",
|
);
|
||||||
});
|
expect(deps.transaction).toHaveBeenCalledWith(expect.any(Function), {
|
||||||
|
isolationLevel: "read committed",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const articleDeps = dependencies();
|
it.each(
|
||||||
await articleDeps.adapter.execute(
|
CONTENT_DATABASE_OPERATIONS.filter(
|
||||||
"article.change",
|
(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 },
|
{ action: "update", id: 7 },
|
||||||
mutationContext,
|
mutationContext,
|
||||||
);
|
);
|
||||||
expect(articleDeps.transaction).toHaveBeenCalledWith(
|
expect(deps.transaction).toHaveBeenCalledWith(
|
||||||
expect.any(Function),
|
expect.any(Function),
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function createContentProductionMutationAdapter(
|
|||||||
async execute(operation, input, context) {
|
async execute(operation, input, context) {
|
||||||
if (includesOperation(CONTENT_DATABASE_OPERATIONS, operation)) {
|
if (includesOperation(CONTENT_DATABASE_OPERATIONS, operation)) {
|
||||||
const transactionOptions =
|
const transactionOptions =
|
||||||
operation === "poll.change"
|
operation === "poll.change" || operation === "poll-question.change"
|
||||||
? ({ isolationLevel: "read committed" } as const)
|
? ({ isolationLevel: "read committed" } as const)
|
||||||
: undefined;
|
: undefined;
|
||||||
return dependencies.transaction(async (transaction) => {
|
return dependencies.transaction(async (transaction) => {
|
||||||
|
|||||||
Reference in new issue
Block a user