Repository navigation
Conversation
When several filters shared a prefix, e.g. `developers__given_name` and `developers__family_name`, each one replaced the nested dict created by the previous one, so all but the last were silently dropped. The nested dicts are now merged.
A list of filter values, e.g. `SoftwareVersion.list(client, developers__family_name=["Baggins", "Oakenshield"])`, is now expressed in the generated KG query by repeating the top-level property once per value, each copy being required and carrying a single value. A result must therefore match every value, in any order. Previously the list was sent as the value of a single filter, which the KG rejects with a 500 error, and a list of linked objects raised an AttributeError. A one-item list is treated as a single value. An empty list, or more than one list within the same top-level property, raises a ValueError. A list of ID strings is now accepted for a link property, as a single ID string already was.
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.
Currently, passing a list of values as a filter does not work. For example:
sends the list as the value of a single filter, which the KG rejects with a 500 error, and a list of linked objects (e.g.
Chapter.list(client, authors=[p1, p2])) raises anAttributeErrorwhile the query is being generated.This PR expresses a list of values in the generated KG query by repeating the top-level property once per value, each copy being required and carrying a single value:
{"propertyName": "Qdevelopers1", "path": ".../developer", "required": true, "structure": [{"propertyName": "Qfamily_name", "path": ".../familyName", "filter": {"op": "CONTAINS", "value": "Baggins"}, "required": true}]}, {"propertyName": "Qdevelopers2", "path": ".../developer", "required": true, "structure": [{"propertyName": "Qfamily_name", "path": ".../familyName", "filter": {"op": "CONTAINS", "value": "Oakenshield"}, "required": true}]}A result must therefore match every value in the list, in any order.
ValueError, as does more than one list within the same top-level property (e.g. lists for bothdevelopers__family_nameanddevelopers__given_name), since there is no way to pair the items.EqualsandRegexvalues in a list keep their own operator.The PR also fixes
expand_filter(), which currently drops all but the last of several filters sharing a prefix, e.g.developers__given_nameanddevelopers__family_name(separate commit).This is a first step towards supporting list-valued properties in existence queries:
_build_existence_query()currently raisesCannotBuildExistenceQuery("not implemented yet")for them, so objects such as aFilewithhashesare always treated as new when saved.Tests
test/test_queries.py, and ofexpand_filter()intest/test_utility.py.test_execute_query_with_list_filter, checks against the KG that filtering software versions on a list of two developer family names returns exactly the overlap between the two single-name queries. Previously, this test would have failed, producing a 500 error from the KG.