mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 16:12:05 +00:00
fix: bind proposal claims to players
This commit is contained in:
@@ -32,7 +32,7 @@ func CreateProposal(ctx context.Context, db *sql.DB, proposal domain.Proposal, t
|
||||
if _, err := tx.ExecContext(ctx, ProposalParticipantInsertSQL, proposal.ProposalID, participant.PlayerID, ticketID); err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := tx.ExecContext(ctx, QueueTicketProposeSQL, ticketID, now)
|
||||
result, err := tx.ExecContext(ctx, QueueTicketProposeSQL, ticketID, participant.PlayerID, now)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -79,5 +79,5 @@ FOR UPDATE SKIP LOCKED`
|
||||
VALUES ($1, $2, $3, 'PENDING')`
|
||||
|
||||
QueueTicketProposeSQL = `UPDATE queue_tickets SET state = 'PROPOSED', revision = revision + 1
|
||||
WHERE ticket_id = $1 AND state = 'QUEUED' AND expires_at > $2`
|
||||
WHERE ticket_id = $1 AND player_id = $2 AND state = 'QUEUED' AND expires_at > $3`
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestRetryableRecognisesPostgresSerializationAndDeadlockErrors(t *testing.T)
|
||||
}
|
||||
|
||||
func TestClaimSQLContainsDurableOwnershipFences(t *testing.T) {
|
||||
for _, fragment := range []string{"FOR UPDATE SKIP LOCKED", "state = 'QUEUED'", "proposal_participants", "revision = revision + 1", "INSERT INTO proposals", "ranked_season_rollovers", "ON CONFLICT (player_id, season_id) DO NOTHING"} {
|
||||
for _, fragment := range []string{"FOR UPDATE SKIP LOCKED", "state = 'QUEUED'", "player_id = $2", "proposal_participants", "revision = revision + 1", "INSERT INTO proposals", "ranked_season_rollovers", "ON CONFLICT (player_id, season_id) DO NOTHING"} {
|
||||
if !containsAnySQL(fragment) {
|
||||
t.Fatalf("claim boundary missing %q", fragment)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user