• 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
Screenshots Loading commit data...
app Loading commit data...
bootstrap Loading commit data...
config Loading commit data...
database Loading commit data...
docker Loading commit data...
docs Loading commit data...
docs-site Loading commit data...
gap-filling-plans Loading commit data...
marketing-site Loading commit data...
plans Loading commit data...
public Loading commit data...
reference/oc-sport Loading commit data...
resources Loading commit data...
routes Loading commit data...
scripts Loading commit data...
storage Loading commit data...
tests Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.env.example Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.npmrc Loading commit data...
Beanding Guide.txt Loading commit data...
CLAUDE.md Loading commit data...
Dockerfile Loading commit data...
README.md Loading commit data...
artisan Loading commit data...
captain-definition Loading commit data...
composer.json Loading commit data...
composer.lock Loading commit data...
deploy.sh Loading commit data...
elcaptain-sportsonly-db.md Loading commit data...
one-click-app.yml Loading commit data...
package-lock.json Loading commit data...
package.json Loading commit data...
phpunit.xml Loading commit data...
system info.txt Loading commit data...
vite.config.js Loading commit data...
نادى الشيخ زايد كشف بيانات اللاعبين (2).html Loading commit data...