Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#27143 closed Bug (fixed)

SearchQuery is not combinable using more than one `&` or `|` operators

Reported by: Nicola Jordan Owned by: Tim Graham <timograham@…>
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() -> Error
  • SearchQuery() & SearchQuery() & SearchQuery() -> Error

Expected behaviour would be that these do work as well.

Change History (5)

comment:1 Changed 17 months ago by Josh Smeaton

Cc: josh.smeaton@… added
Triage Stage: UnreviewedAccepted
Version: 1.10master

comment:2 Changed 17 months ago by Josh Smeaton

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.

Last edited 17 months ago by Nicola Jordan (previous) (diff)

comment:3 Changed 17 months ago by Tim Graham

Has patch: set
Patch needs improvement: set
Version: master1.10

PR. Please uncheck "Patch needs improvement" after you update it.

comment:4 Changed 17 months ago by Tim Graham <timograham@…>

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In 978a00e:

Fixed #27143 -- Allowed combining SearchQuery with more than one & or | operators.

comment:5 Changed 17 months ago by Tim Graham <timograham@…>

In 1f3c66fe:

[1.10.x] Fixed #27143 -- Allowed combining SearchQuery with more than one & or | operators.

Backport of 978a00e39fee25cfa99065285b0de88366710fad from master

Note: See TracTickets for help on using tickets.
Back to Top