From c6a7c23187a11ac68708c8f4dbcb8056086fba8c Mon Sep 17 00:00:00 2001 From: Maud Royer Date: Fri, 6 Sep 2024 11:41:09 +0200 Subject: [PATCH] fix(search): error when no substance match Signed-off-by: Maud Royer --- src/app/rechercher/page.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/rechercher/page.tsx b/src/app/rechercher/page.tsx index d36d226..0775d60 100644 --- a/src/app/rechercher/page.tsx +++ b/src/app/rechercher/page.tsx @@ -20,10 +20,12 @@ async function getSpecialites(specialitesId: string[], substancesId: string[]) { .selectFrom("Specialite") .leftJoin("Composant", "Specialite.SpecId", "Composant.SpecId") .where(({ eb }) => - eb.or([ - eb("Specialite.SpecId", "in", specialitesId), - eb("Composant.NomId", "in", substancesId), - ]), + substancesId.length + ? eb.or([ + eb("Specialite.SpecId", "in", specialitesId), + eb("Composant.NomId", "in", substancesId), + ]) + : eb("Specialite.SpecId", "in", specialitesId), ) .where("Specialite.SpecId", "in", liste_CIS_MVP) .selectAll("Specialite")