#27143 closed Bug (fixed)
SearchQuery is not combinable using more than one `&` or `|` operators
Reported by: | Nicola Jordan | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 1.10 |
Severity: | Normal | Keywords: | Search |
Cc: | josh.smeaton@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
I think there is a bug/oversight on the SearchQuery implementation.
Working examples:
SearchQuery() & SearchQuery()
SearchQuery() | SearchQuery()
SearchQuery() | SearchQuery() & SearchQuery()
But using multiple of the same "concatenators" does not:
SearchQuery() & SearchQuery() & SearchQuery()
-> ErrorSearchQuery() & SearchQuery() & SearchQuery()
-> Error
Expected behaviour would be that these do work as well.
Change History (5)
comment:1 by , 8 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.10 → master |
comment:3 by , 8 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Version: | master → 1.10 |
PR. Please uncheck "Patch needs improvement" after you update it.
Note:
See TracTickets
for help on using tickets.
More detail here: https://groups.google.com/forum/#!topic/django-developers/hTj7NLXu2xw
Copying the likely fix:
SearchQuery defines its own operators to work around the limitation in Combinable, but fails to take into account that when two SearchQuery instances are combined, you're returned a CombinedExpression (containing SearchQueries). SearchVector *does* take this into consideration though.The fix would be to define a SearchQueryCombinable Mixin that looks very similar to SearchVectorCombinable, and override the various or and and methods, as the SearchQuery type does itself.