Opened 10 years ago

Closed 9 years ago

Last modified 9 years 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 by Josh Smeaton, 10 years ago

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

comment:2 by Josh Smeaton, 10 years ago

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.

Version 0, edited 10 years ago by Josh Smeaton (next)

comment:3 by Tim Graham, 10 years ago

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

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

comment:4 by Tim Graham <timograham@…>, 9 years ago

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 by Tim Graham <timograham@…>, 9 years ago

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