add optional swapped with, allows check for swapped given_name/name fields - #640
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the duplicate-contact detection logic so that contacts are also detected as duplicates when given_name and name were entered swapped (e.g., John Doe vs Doe John). It updates the duplicate similarity SQL generation and its prefilter (“blocking”) logic, and adds a regression test plus a changelog entry.
Changes:
- Add
swapped_withmetadata to compared columns to express name/given-name swap counterparts. - Extend similarity scoring and blocking conditions to treat consistent swaps as a match (while keeping the block selective by requiring both swap directions).
- Add an Alcotest regression case for swapped
firstname/lastname, and document the behavior change in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pool/test/duplicate_contacts_test.ml |
Adds a test asserting swapped first/last names are detected as duplicates with score 1.0. |
pool/app/duplicate_contacts/repo.ml |
Updates generated SQL for similarity scoring and blocking to account for swapped name/given_name pairs. |
pool/app/duplicate_contacts/entity.ml |
Introduces Column.swapped_with and configures swap pairing for name ↔ given_name. |
CHANGELOG.md |
Notes the duplicate-check behavior change under unreleased. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PossessedC0bra
self-requested a review
August 31, 2026 13:10
PossessedC0bra
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.