Let the database decide whether a reaction is already there

Fixkamo-shared-library
Ya
27 Agosti 2026, 01:59 UTC
Mwandishi
kamo
Ahadi ya
02b6153

The unique constraint on (message, member, emoji) was doing nothing useful. A read-then-save loses the race with the member's own second click, and catching the resulting violation is worse than useless: it surfaces at flush, which is normally after the catch block, and by then the transaction is already marked rollback-only — so the "safe under a double-click" the constraint was there for would have arrived as a 500. insertIfAbsent is an ON CONFLICT DO NOTHING upsert keyed on that constraint, which is the only place the question can be answered atomically.

Mabadiliko yote

Je, unaona nini kuhusu usafiri?

Kila moja ya hizi updates ardhi katika nafasi yako ya kazi moja kwa moja. Kuanza bure na kuangalia kukua wiki baada ya wiki.

Kuwa Huru MileleMtazamo wa bei