From bc532b95e643198219e088442065d95841c89183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 12 Sep 2026 08:14:08 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20board=5Fstroke::history?= =?UTF-8?q?=20clause=20placeholders=20follow=20positional=20bind=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/board_stroke.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/db/board_stroke.rs b/src/db/board_stroke.rs index 9277e72..0b10745 100644 --- a/src/db/board_stroke.rs +++ b/src/db/board_stroke.rs @@ -216,8 +216,8 @@ pub async fn clear(db: &Database, board: &BoardId, by: &UserId) -> Result, offset: i64, ) -> Result<(Vec, i64), AppError> { - let scope = match epoch { - Some(_) => " AND epoch = $2", - None => "", + // The builder binds positionally in call order, so each optional clause + // takes the placeholder number its position in the bind sequence gives + // it — epoch (when present) is always $2, the marker filter $3 only + // when the epoch clause is there too. + let (scope, kinds) = match (epoch.is_some(), marks_only) { + (true, true) => (" AND epoch = $2", " AND kind != $3"), + (true, false) => (" AND epoch = $2", ""), + (false, true) => ("", " AND kind != $2"), + (false, false) => ("", ""), }; - let kinds = if marks_only { " AND kind != $3" } else { "" }; let mut list = PagedList::new( format!("board_stroke WHERE board = $1{scope}{kinds}"), "ORDER BY id", ) .bind(board.uuid()); - if epoch.is_some() { - list = list.bind(epoch.unwrap_or_default()); + if let Some(epoch) = epoch { + list = list.bind(epoch); } if marks_only { list = list.bind(KIND_CLEAR.to_string());