fix(bookings): use transaction context for discount check in approve edit

Use tx.QueryRow instead of db.Conn.QueryRow for discount count check in AdminApproveEditRequestHandler to ensure consistency within the transaction.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-06-22 17:06:18 +01:00
co-authored by Sisyphus
parent 80b9877686
commit 37a9ba3517
+1 -1
View File
@@ -1729,7 +1729,7 @@ func AdminApproveEditRequestHandler(w http.ResponseWriter, r *http.Request) {
// Check for applied discounts (admin warning only — discounts remain locked in) // Check for applied discounts (admin warning only — discounts remain locked in)
var discountCount int var discountCount int
if err := db.Conn.QueryRow(r.Context(), `SELECT COUNT(*) FROM booking_discounts WHERE booking_id = $1`, bookingID).Scan(&discountCount); err != nil { if err := tx.QueryRow(r.Context(), `SELECT COUNT(*) FROM booking_discounts WHERE booking_id = $1`, bookingID).Scan(&discountCount); err != nil {
log.Printf("ADMIN APPROVE EDIT: Failed to check discounts: %v", err) log.Printf("ADMIN APPROVE EDIT: Failed to check discounts: %v", err)
} }
if discountCount > 0 { if discountCount > 0 {