From 1a46a1deea53e1393e404514a62460bdee440e0b Mon Sep 17 00:00:00 2001 From: Etan Joseph Heyman Date: Sun, 22 Feb 2026 04:05:36 +0200 Subject: [PATCH] nightshift: fix broken Convex filter in toggleLineLearned The filter used JavaScript && between Convex query expressions: q.eq(q.field("songId"), ...) && q.eq(q.field("lineNumber"), ...) Since && returns the right operand when the left is truthy (any object), this silently dropped the songId filter. The mutation could toggle the wrong line's learned state when a user has multiple songs with matching line numbers. Fixed by using q.and() to properly combine both filter conditions. Co-Authored-By: Claude Opus 4.6 --- convex/songProgress.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/convex/songProgress.ts b/convex/songProgress.ts index fd43f94..d497e63 100644 --- a/convex/songProgress.ts +++ b/convex/songProgress.ts @@ -236,8 +236,10 @@ export const toggleLineLearned = mutation({ q.eq("userId", userId) ) .filter((q) => - q.eq(q.field("songId"), args.songId) && - q.eq(q.field("lineNumber"), args.lineNumber) + q.and( + q.eq(q.field("songId"), args.songId), + q.eq(q.field("lineNumber"), args.lineNumber) + ) ) .first();