From e27eb8e927062e000166e6c69a82a9f6d22ab867 Mon Sep 17 00:00:00 2001 From: Suriyakumarvijayanayagam Date: Tue, 29 Sep 2026 16:07:43 +0530 Subject: [PATCH] A discarded phone number was kept and could not be found The merge records what it had to discard in the survivor's notes, and search did not look there - so the value was retained and unfindable, which answers the letter of "nothing is lost" and not the point of it. A customer reached by their old number is exactly who somebody is looking for when they type it. Caught in the same patch: I wrote ESCAPE with two backslashes where the four clauses beside it use one. In a Go raw string that is two literal backslashes, and Postgres requires the escape to be a single character - it would have failed the whole customer search at runtime, on a query no in-memory test executes. All five clauses are identical now. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KGcjxF1cNLcuwc3DAPcnfj --- server/internal/store/api_people.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/internal/store/api_people.go b/server/internal/store/api_people.go index 1e211e7..794c5de 100644 --- a/server/internal/store/api_people.go +++ b/server/internal/store/api_people.go @@ -59,7 +59,13 @@ func (s *Store) SearchVisitors(ctx context.Context, clientID, query string, limi OR v.label ILIKE $3 ESCAPE '\' OR p.full_name ILIKE $3 ESCAPE '\' OR p.phone ILIKE $3 ESCAPE '\' - OR p.email ILIKE $3 ESCAPE '\') + OR p.email ILIKE $3 ESCAPE '\' + -- Notes are searched for ONE reason: a merge records the + -- phone and name it had to discard there, and a customer + -- reached by their old number is exactly who somebody is + -- looking for when they type it. Retained-but-unfindable + -- answers the letter of "nothing is lost" and not the point. + OR p.notes ILIKE $3 ESCAPE '\') ORDER BY v.last_seen_at DESC NULLS LAST, v.first_seen_at DESC LIMIT $4`, clientID, strings.TrimSpace(query), likePattern(strings.TrimSpace(query)),