fix: empty _Row truthy bug in add_contact UPSERT

fetchone() returns an empty _Row on no match (no __bool__), so  was
always true and UPDATE ran with a nonexistent id, silently inserting nothing.
Changed to  so missing rows fall through to INSERT.
This commit is contained in:
jp
2026-08-13 13:39:07 +01:00
parent b09255473a
commit 247c8f7318

View File

@ -511,7 +511,7 @@ async def add_contact(request: Request, vm_session: str = Cookie(default=None)):
row = con.execute(
"SELECT id FROM contacts WHERE number_e164 = ?", (normalized,)
).fetchone()
if row:
if row and row.get("id"):
con.execute(
"UPDATE contacts SET name=?, email=?, updated_at=NOW() WHERE id=?",
(name, email, row["id"]),