Per code review audit (May 14): transaction correctness bug в
`sync_pzz_zones_to_db()` — inner `db.rollback()` в loop сбрасывал outer
transaction на per-row failures → counts inserted/updated НЕ matched DB state.
## Fix
Wrap UPSERT в loop через `db.begin_nested()` (SAVEPOINT):
- Failure одной row → rollback только её savepoint, outer tx alive
- Successfully inserted rows accumulate в outer tx → commit final
- Outer try/except добавлен для unexpected error → rollback + log + raise
- `finally: db.close()` preserved
Pattern consistent с `domrf_kn.py` (где SAVEPOINT уже работает).
## Preserved
- Function signature + return shape {fetched, inserted, updated, skipped} — unchanged
- Logging contracts
- skipped count теперь корректно включает DB-failure rows (consistent with prior behavior)
## Tests
- No test_pzz_loader.py — skipped
- ruff + AST passed
## Vault
`fixes/Bug_Pzz_Loader_Missing_Savepoint_May14.md` — created (status: resolved).
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| cadastre_fetch.py | ||
| filters.py | ||
| noise_loader.py | ||
| parser.py | ||
| poi_loader.py | ||
| pzz_loader.py | ||
| quarter_dump_lookup.py | ||
| scorer.py | ||