瀏覽代碼

fix: UpdateStatus SQL — разделить параметр \ чтобы избежать type conflict в pgx

neyrogovnarik 1 月之前
父節點
當前提交
43b629359d
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      backend/internal/repository/places.go

+ 3 - 3
backend/internal/repository/places.go

@@ -157,9 +157,9 @@ func (r *PlaceRepo) Update(ctx context.Context, p *models.Place) error {
 func (r *PlaceRepo) UpdateStatus(ctx context.Context, id, status, comment string) error {
 	_, err := r.pool.Exec(ctx,
 		`UPDATE places SET status=$1, moderation_comment=$2, updated_at=now(),
-		 published_at = CASE WHEN $1 = 'published' THEN now() ELSE published_at END
-		 WHERE id=$3 AND deleted_at IS NULL`,
-		status, comment, id)
+		 published_at = CASE WHEN $3 THEN now() ELSE published_at END
+		 WHERE id=$4 AND deleted_at IS NULL`,
+		status, comment, status == "published", id)
 	return err
 }