fix(sqlalchemy): убрать :name::type — psycopg3 их не парсит, ломает Phase A INSERT в kn_scrape_runs (run_region_sweep крашится сразу с ProgrammingError, task_received записан, но run_id никогда не создаётся). 4 места: domrf_kn.py (resume INSERT, new run INSERT, snapshot UPDATE) + admin_leads.py (date_to filter). Заменено на CAST(:name AS type).

This commit is contained in:
lekss361 2026-04-28 23:37:03 +03:00
parent c3bc96535d
commit d1f2380f32
2 changed files with 5 additions and 5 deletions

View file

@ -67,7 +67,7 @@ def list_leads(
where.append("l.created_at >= :date_from")
params["date_from"] = date_from
if date_to:
where.append("l.created_at < (:date_to::date + INTERVAL '1 day')")
where.append("l.created_at < (CAST(:date_to AS date) + INTERVAL '1 day')")
params["date_to"] = date_to
if search:
where.append("(l.name ILIKE :search OR l.phone_last4 = :exact_search)")

View file

@ -1021,8 +1021,8 @@ async def run_region_sweep(
total_obj_count, heartbeat_at, resumed_from_run_id
)
VALUES (
:rc::int[], :devs::text[], :snap, 'running',
:params::jsonb, :objs::jsonb, :idx,
CAST(:rc AS int[]), CAST(:devs AS text[]), :snap, 'running',
CAST(:params AS jsonb), CAST(:objs AS jsonb), :idx,
:total, NOW(), :prev
)
RETURNING run_id
@ -1057,7 +1057,7 @@ async def run_region_sweep(
)
VALUES (
ARRAY[:rc]::int[], CAST(:devs AS text[]), :snap, 'running',
:params::jsonb, NOW()
CAST(:params AS jsonb), NOW()
)
RETURNING run_id
"""
@ -1141,7 +1141,7 @@ async def run_region_sweep(
text(
"""
UPDATE kn_scrape_runs
SET objects_snapshot = :objs::jsonb,
SET objects_snapshot = CAST(:objs AS jsonb),
total_obj_count = :total,
objects_count = :total,
heartbeat_at = NOW()