• Mahmoud Aglan's avatar
    fix(financial): stop binding NULL as a filter Postgres cannot type · 75fbca7a
    Mahmoud Aglan authored
    The financial overview 500'd with SQLSTATE 42P08 on `($4 IS NULL OR
    p.branch_id = $4)`. Postgres fixes each prepared-statement parameter's type
    during parse analysis, and `:branch_id IS NULL` gives it nothing to work from
    — the statement is rejected before it ever reaches the comparison that would
    have typed it. `:academy_id` was the same shape and would have failed next.
    
    The idiom came in with 35200985 and could not be caught here: phpunit runs
    SQLite in memory, which types placeholders at bind time and executes the
    broken form happily.
    
    Fixed by appending the branch and academy filters only when they apply, with
    their bindings, rather than passing NULL as a sentinel — which is what the
    ->when() filters in the same method already do, and keeps the
    (academy_id, branch_id) index usable instead of hiding it behind an OR.
    
    The SQL build is extracted to buildTopProgramsQuery() so it can be asserted on
    without a database. The test pins four things: the placeholders and the
    bindings agree in all four filter combinations, the clauses are omitted rather
    than nulled, the built SQL executes, and no raw SQL under app/ binds a
    placeholder as a NULL sentinel again. That last one is a source scan on
    purpose — the suite's driver is not the production driver, so it cannot
    observe this failure by running.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    75fbca7a
Name
Last commit
Last update
..
Activities Loading commit data...
Admin Loading commit data...
Assignments Loading commit data...
Attendance Loading commit data...
Audit Loading commit data...
Auth Loading commit data...
Branches Loading commit data...
CashSessions Loading commit data...
Components Loading commit data...
Concerns Loading commit data...
Dashboard Loading commit data...
Documents Loading commit data...
Enrollments Loading commit data...
Evaluations Loading commit data...
Events Loading commit data...
Facilities Loading commit data...
Financial Loading commit data...
Groups Loading commit data...
Guardian Loading commit data...
HR Loading commit data...
Inventory Loading commit data...
Invoices Loading commit data...
Messaging Loading commit data...
Notifications Loading commit data...
POS Loading commit data...
Parent Loading commit data...
Participants Loading commit data...
People Loading commit data...
Pricing Loading commit data...
Profile Loading commit data...
Programs Loading commit data...
Public Loading commit data...
Receptionist Loading commit data...
Reports Loading commit data...
Roles Loading commit data...
Schedule Loading commit data...
Settings Loading commit data...
Trainer Loading commit data...
Training Loading commit data...
Users Loading commit data...
Wallets Loading commit data...
Website Loading commit data...
WhatsApp Loading commit data...
Wizards Loading commit data...
BranchSwitcher.php Loading commit data...
Dashboard.php Loading commit data...
GlobalSearch.php Loading commit data...