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:
@ -511,7 +511,7 @@ async def add_contact(request: Request, vm_session: str = Cookie(default=None)):
|
|||||||
row = con.execute(
|
row = con.execute(
|
||||||
"SELECT id FROM contacts WHERE number_e164 = ?", (normalized,)
|
"SELECT id FROM contacts WHERE number_e164 = ?", (normalized,)
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if row:
|
if row and row.get("id"):
|
||||||
con.execute(
|
con.execute(
|
||||||
"UPDATE contacts SET name=?, email=?, updated_at=NOW() WHERE id=?",
|
"UPDATE contacts SET name=?, email=?, updated_at=NOW() WHERE id=?",
|
||||||
(name, email, row["id"]),
|
(name, email, row["id"]),
|
||||||
|
|||||||
Reference in New Issue
Block a user