fix(db): converge ticket filter builder; audit count_query placeholder family #211
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-197-audit-count-query-placeholder-family"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Audit the remaining dynamic count_query / where-placeholder list sites that the May-21 mass merge introduced and PR #85 / PMS-178 never reviewed. The latent bug is a filter placeholder that collides with the appended LIMIT/OFFSET binds, so any filtered list 500s while the no-filter read works.
The five audit-only sites (time_tracking::list_time_entries, time_tracking::list_timesheets, calendar::list_appointments, knowledge_base::list_articles, contracts::list_contracts) already number placeholders correctly: filters are numbered for both the data and count query, LIMIT/OFFSET bind last, and the shared/parallel clauses bind identically. They were missing only regression coverage, now added in tests/list_filter_pagination.rs (one service-level test per site, every filter combination plus a non-zero-offset page, mirroring the intent of tests/audit_list.rs).
Audit fixes: extract the filter builder duplicated verbatim between tickets::list_tickets and tickets::list_ticket_responses into a single build_ticket_filter_sql helper so the data/count placeholder numbering can no longer diverge (the is_open fragment, the only per-caller difference, is passed in). The helper now also advances data_idx/count_idx after assigned_to_id (the previously-missing increment that left a placeholder filter added below it mis-numbered). Restore the commented-out param_idx increments on the last conditional field in tenants::update_tenant (branding) and auth::update_user (date_format_string), each guarded by #[allow(unused_assignments)] with the bind-order invariant documented, so the copy-paste pattern stays safe when a field is appended.
#PMS-197