Skip to content

Fixing comment downvote after an upvote.#6370

Merged
Nutomic merged 2 commits intomainfrom
fix-comment-votes-1
Mar 2, 2026
Merged

Fixing comment downvote after an upvote.#6370
Nutomic merged 2 commits intomainfrom
fix-comment-votes-1

Conversation

@dessalines
Copy link
Copy Markdown
Member

- The culprit was an incorrect on_conflict trigger, which needed to be
converted to a `MERGE` to handle the multiple unique keys: (person_id,
post_id) and (person_id, comment_id)
- Fixes #6103
@dullbananas
Copy link
Copy Markdown
Collaborator

Be careful with merge, because it handles concurrency differently, and a transaction is not necessarily enough to make it work properly. I'm not totally sure if this merge statement is fine.

I recommend adding a check that throws an error (which undoes the transaction) if the merge statement did not affect the correct number of rows, to avoid leaving inconsistent state in the database.

@dessalines
Copy link
Copy Markdown
Member Author

Turns out I didn't need merge, just needed to change post_id to thing_id

@Nutomic Nutomic merged commit 8b270b3 into main Mar 2, 2026
2 checks passed
@Nutomic Nutomic deleted the fix-comment-votes-1 branch March 2, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unnecessary PostActions::remove_like call

3 participants