refactor(backend): migrate from sql.ErrNoRows to pgx.ErrNoRows
Replace all database/sql.ErrNoRows checks with pgx.ErrNoRows across backend handlers. Migration includes: jwt.go, local.go, admin_reserve.go, custom_services.go, discount_campaigns.go, services.go, account.go, customer_relationship.go, guest.go. Also removes unused test_helpers.go resetTestData function. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -4,12 +4,12 @@ import (
|
||||
"context"
|
||||
"crussell/auth"
|
||||
"crussell/db"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"crussell/internal/dav"
|
||||
"crussell/internal/validators"
|
||||
"crussell/internal/zxcvbnjs"
|
||||
"crussell/mw"
|
||||
"crypto/rand"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -520,7 +520,7 @@ func GenerateVerificationCodeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
"SELECT id FROM users WHERE LOWER(email) = $1", email,
|
||||
).Scan(&userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(VerificationResponse{Success: true, Message: "If the email exists, a verification code will be sent"})
|
||||
return
|
||||
@@ -576,7 +576,7 @@ func VerifyCodeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
code,
|
||||
).Scan(&userID, &purpose, &expiresAt)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
// Check if code exists but was already used or expired
|
||||
var checkUsedAt *time.Time
|
||||
checkErr := db.DB.QueryRow(r.Context(),
|
||||
|
||||
Reference in New Issue
Block a user