Skip to content

Match existence queries exactly by default, and add an existence_match option - #152

Merged
apdavison merged 1 commit into
HumanBrainProject:masterfrom
apdavison:exact-existence-matching
Sep 29, 2026
Merged

apdavison merged 1 commit into
HumanBrainProject:masterfrom
apdavison:exact-existence-matching

Conversation

@apdavison

Copy link
Copy Markdown
Member

Fixes #149

…h option

The existence query used by exists() and save() filtered string properties with the KG's CONTAINS operator, so a new Dataset called FOO was identified with an existing one called FOO-BAR and silently overwrote it (#149). Existence queries now use EQUALS, which the KG applies case-insensitively but not whitespace-insensitively, so a stored name with a trailing space is no longer found by a local name without one.

exists() and save() take a new existence_match argument, either "equals" (the default, matching name_matching.MATCH_TYPES) or "contains" to restore the old behaviour; save() passes it on to child objects. The save cache holds a match found with "contains" under a separate key, so that it is not later returned for an "equals" lookup. Collection.upload() does not expose the option and always matches exactly.

The exact match is implemented by a new Equals filter value, the counterpart of Regex, which selects the EQUALS operator in place of CONTAINS. It is exported from fairgraph and documented in the API reference and the queries guide. A list of Equals values is not supported and falls back to CONTAINS, as for Regex (#150).

MockKGClient in test/utils.py gained matching case-insensitive EQUALS handling.
@apdavison apdavison added this to the 0.16 milestone Sep 28, 2026
@apdavison
apdavison merged commit 73b0751 into HumanBrainProject:master Sep 29, 2026
6 checks passed
@apdavison
apdavison deleted the exact-existence-matching branch September 29, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Existence check matches by substring, so saving a new Dataset can overwrite a different one

1 participant