From d125d2e36516d298b2774fc1f4c16fd74a22babb Mon Sep 17 00:00:00 2001 From: Experiments DB Dev Date: Thu, 23 Apr 2026 14:54:08 -0400 Subject: [PATCH] fix: filter analysis_summary in JS instead of Prisma WHERE clause MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prisma 5 rejects both null and Prisma.DbNull as WHERE filter values for Json? fields (no clean IS NOT NULL operator). Filter the result array in JS after the query — the output is immediately cached so this only runs once per cache period. Co-Authored-By: Claude Sonnet 4.6 --- backend/src/routes/experiments.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/src/routes/experiments.js b/backend/src/routes/experiments.js index 1db58e1..2581c29 100644 --- a/backend/src/routes/experiments.js +++ b/backend/src/routes/experiments.js @@ -1,6 +1,5 @@ const router = require('express').Router(); const { body } = require('express-validator'); -const { Prisma } = require('@prisma/client'); const prisma = require('../lib/prisma'); const cache = require('../lib/cache'); const auditMiddleware = require('../middleware/auditMiddleware'); @@ -373,11 +372,8 @@ router.get('/:id/daily-statuses', async (req, res, next) => { const next = new Date(d); next.setUTCDate(next.getUTCDate() + 1); where.date = { gte: d, lt: next }; } - if (analysisOnly) { - where.NOT = { analysis_summary: Prisma.DbNull }; - } - const statuses = await prisma.dailyStatus.findMany({ + let statuses = await prisma.dailyStatus.findMany({ where, select: { id: true, @@ -393,6 +389,12 @@ router.get('/:id/daily-statuses', async (req, res, next) => { orderBy: { date: 'asc' }, }); + // Prisma 5 has no clean IS NOT NULL filter for Json? fields; filter in JS. + // The result is cached so this only runs once per cache period. + if (analysisOnly) { + statuses = statuses.filter((s) => s.analysis_summary !== null); + } + cache.set(cacheKey, statuses); res.json(statuses); } catch (err) { next(err); }