fix: recherche insensible à la casse et aux accents dans tous les filtres
- utils/search.ts : normalize() (NFD + minuscules) + matchesSearch() - ShoppingPage filteredProducts : matchesSearch sur nom ET marque - Backend searchProducts : ilike sur nom ET marque (or_) - Notes FTS : déjà insensible nativement (plainto_tsquery) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import uuid
|
||||
from datetime import datetime, timezone
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from fastapi.responses import Response
|
||||
from sqlalchemy import select, text
|
||||
from sqlalchemy import select, text, or_
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
@@ -104,7 +104,7 @@ async def search_products(
|
||||
):
|
||||
stmt = select(Product).order_by(Product.frequency_score.desc(), Product.name)
|
||||
if q:
|
||||
stmt = stmt.where(Product.name.ilike(f"%{q}%"))
|
||||
stmt = stmt.where(or_(Product.name.ilike(f"%{q}%"), Product.brand.ilike(f"%{q}%")))
|
||||
stmt = stmt.limit(limit)
|
||||
result = await session.execute(stmt)
|
||||
return result.scalars().all()
|
||||
|
||||
Reference in New Issue
Block a user