From c9df9feccdb7243ae751d8808d6e70ed68ff4898 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Tue, 31 Mar 2026 10:27:32 +0200 Subject: [PATCH] fix: replace IN() with OR conditions in analytics SQL for Drizzle compatibility Co-Authored-By: Claude Sonnet 4.6 --- src/lib/pg-ff-client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/pg-ff-client.ts b/src/lib/pg-ff-client.ts index 0181344..c960ecd 100644 --- a/src/lib/pg-ff-client.ts +++ b/src/lib/pg-ff-client.ts @@ -655,11 +655,11 @@ export async function pgGetCaByFournisseur( JOIN articles a ON a.no_id = m.artnoid JOIN artfou1 af ON af.art_no_id = a.no_id JOIN fouadr1 f ON f.code = af.code AND f.sit_code = '000' - WHERE TO_CHAR(m.datmvt, 'YYYY-MM') IN (${mois}, ${moisN1}) + WHERE (TO_CHAR(m.datmvt, 'YYYY-MM') = ${mois} OR TO_CHAR(m.datmvt, 'YYYY-MM') = ${moisN1}) AND m.site IN ('292', '579') AND m.genremvt = 3 GROUP BY af.code, m.site, TO_CHAR(m.datmvt, 'YYYY-MM') - ORDER BY af.code, m.site, mois + ORDER BY af.code, m.site, TO_CHAR(m.datmvt, 'YYYY-MM') `); console.log(`[pg-ff] CaByFournisseur: ${result.rows.length} lignes pour ${mois}/${moisN1}`); @@ -683,11 +683,11 @@ export async function pgGetCaByNomenclature( FROM mvtart m JOIN articles a ON a.no_id = m.artnoid JOIN nomenclature n ON n.no_id = a.nom_no_id - WHERE TO_CHAR(m.datmvt, 'YYYY-MM') IN (${mois}, ${moisN1}) + WHERE (TO_CHAR(m.datmvt, 'YYYY-MM') = ${mois} OR TO_CHAR(m.datmvt, 'YYYY-MM') = ${moisN1}) AND m.site IN ('292', '579') AND m.genremvt = 3 GROUP BY n.code, n.libelle, m.site, TO_CHAR(m.datmvt, 'YYYY-MM') - ORDER BY n.code, m.site, mois + ORDER BY n.code, m.site, TO_CHAR(m.datmvt, 'YYYY-MM') `); console.log(`[pg-ff] CaByNomenclature: ${result.rows.length} lignes pour ${mois}/${moisN1}`);