Skip to content

Commit

Permalink
Add where clause in cancel_request stored procedure early exit
Browse files Browse the repository at this point in the history
  • Loading branch information
nilspenzel committed Feb 24, 2025
1 parent b52bf40 commit 24369d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions migrations/2024-07-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ BEGIN
SELECT communicated_time
FROM request r
JOIN event e ON r.id = e.request
WHERE r.id = p_request_id
ORDER BY e.communicated_time ASC
LIMIT 1
) <= p_now THEN
Expand Down
4 changes: 2 additions & 2 deletions src/lib/server/db/cancelRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('tests for cancelling requests', () => {
const e1 = await setEvent(r, Date.now() + 7200, true, 1, 1);
const e2 = await setEvent(r, Date.now() + 7200, false, 1, 1);
const r2 = (await setRequest(t!.id, u.id, '')).id;
await setEvent(r2, 0, true, 1, 1);
await setEvent(r2, 0, false, 1, 1);
await setEvent(r2, Date.now() + 7200, true, 1, 1);
await setEvent(r2, Date.now() + 7200, false, 1, 1);

await cancelRequest(r, u.id);
const events = await selectEvents();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const setEvent = async (
address: '',
cancelled: false
})
.returning('id')
.returning('event.id')
.executeTakeFirstOrThrow()
).id;
};
Expand Down

0 comments on commit 24369d2

Please sign in to comment.