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:
@@ -1729,7 +1729,7 @@ func AdminApproveEditRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Check for applied discounts (admin warning only — discounts remain locked in)
|
||||
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)
|
||||
}
|
||||
if discountCount > 0 {
|
||||
|
||||
Reference in New Issue
Block a user