fix(db): converge ticket filter builder; audit count_query placeholder family #211

Merged
David merged 2 commits from feat/pms-197-audit-count-query-placeholder-family into main 2026-06-13 23:56:13 +02:00
Owner

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

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
fix(db): converge ticket filter builder; audit count_query placeholder family
Some checks failed
E2E / Playwright against staging (pull_request) Failing after 15s
Check / fmt + clippy + compile + tests (pull_request) Failing after 2m38s
d68af1b82c
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
Merge origin/main into feat/pms-197-audit-count-query-placeholder-family
Some checks failed
E2E / Playwright against staging (pull_request) Failing after 23s
Check / fmt + clippy + compile + tests (pull_request) Successful in 4m25s
Create release / Create release from merged PR (pull_request) Has been skipped
4a7c72e3ab
#PMS-197
David merged commit eac8dbb371 into main 2026-06-13 23:56:13 +02:00
David deleted branch feat/pms-197-audit-count-query-placeholder-family 2026-06-13 23:56:13 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!211
No description provided.