gendesign/tradein-mvp/backend
lekss361 4a2a804296 fix(tradein-estimator): restore CAST in IS NOT NULL predicates (revert audit #9)
PR #509 removed CAST(:target_year AS integer) and CAST(:target_house_type AS text)
from the IS NOT NULL predicates in _fetch_analogs, citing audit finding #9 (perf).
This broke production: psycopg3 prepared statement could not determine $4 type
when target_house_type=None, raising AmbiguousParameter at plan time. The CAST
in the THEN branch is not enough — PG planner needs the type to evaluate
IS NOT NULL itself.

The inline comment at lines 814-816 explicitly documented this requirement;
PR #509 misread the audit finding. Per-row CAST cost on ≤300 rows is negligible
vs production breakage. Restoring CAST forms; THEN-branch CASTs untouched
(they were never removed).

Verified prod stack trace 2026-05-24 ~12:25 (target_year=1978, target_house_type=None).
2026-05-24 15:28:36 +03:00
..
app fix(tradein-estimator): restore CAST in IS NOT NULL predicates (revert audit #9) 2026-05-24 15:28:36 +03:00
data/sql fix(tradein-sql): remove duplicate CREATE INDEX from 050 (regression from PR #500) (#515) 2026-05-24 12:16:27 +00:00
tests fix(tradein-estimator): atomic IMV link, batched yandex history, drop redundant CAST (#509) 2026-05-24 11:18:12 +00:00
.dockerignore feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
Dockerfile feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
pyproject.toml fix(tradein-photos): sanitize uploaded images via Pillow re-encode (#511) 2026-05-24 11:32:04 +00:00