Fix q filter fails to search multiple words #81
Merged
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.
Problem
FakeRest’s q filter looks for the passed string in all fields of the resource. This is fine when looking for a company name (e.g. “Acme”), but not when looking for a full name (e.g. “John Doe”) as none of the fields of the resource match the string if the name is split across first_name and last_name. As a result, a search on "John Doe" returns nothing.
Solution
Update the q search to split the input string by white space, search for each word, and combine the results (OR logic)