Feature #35764

Multiple search terms in the "contains" operator of text filters

Added by Go MAEDA 11 months ago. Updated 9 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Filters
Target version:5.0.0
Resolution:Fixed

Description

I extracted the attached patch from #35073#note-4. The patch posted by Jens Krämer from Planio allows you to use multiple search terms in "contains" operator of text filters.

The alternative I am experimenting with right now is breaking up the user's query string into tokens like the global search does, and use these to build a query with multiple LIKE clauses that are combined with AND. I'm attaching a preliminary patch that implements this for the Issue.like scope (used by the autocompleter) and the Query#sql_contains method (which should cover all query filters). Do you think that's a viable approach?

It seems that the patch has already been deployed to the production environment of Planio. See Planio filters just got more powerful - Planio Support (english) - Planio Support


Related issues

Blocked by Redmine - Feature #35073: Escape values in LIKE statements to prevent injection of ... Closed

Associated revisions

Revision 21238
Added by Marius BALTEANU 9 months ago

Tokenize search parameter in order to allow multiple search terms in:
  • the "contains" operator of text filters
  • in issue autocomplete

Patch by Jens Krämer.

Revision 21239
Added by Marius BALTEANU 9 months ago

Add tests for #35764.

Revision 21241
Added by Marius BALTEANU 9 months ago

Disable rubocop Lint/IneffectiveAccessModifier for self.tokenized_like_conditions in app/models/query.rb (#35764).

History

#1 Updated by Go MAEDA 11 months ago

  • Blocked by Feature #35073: Escape values in LIKE statements to prevent injection of placeholders (_ or %) added

#2 Updated by Marius BALTEANU 11 months ago

  • Target version set to 5.0.0

#3 Updated by Marius BALTEANU 9 months ago

  • Assignee set to Marius BALTEANU

#4 Updated by Marius BALTEANU 9 months ago

  • Resolution set to Fixed

Patch committed with tests, thanks for this nice improvement.

The patch introduces the following offense:

Lint/IneffectiveAccessModifier: private (on line 1074) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
  def self.tokenized_like_conditions(db_field, value, **options)

#5 Updated by Marius BALTEANU 9 months ago

  • Status changed from New to Resolved

I've disabled for now the rubocop offense for Lint/IneffectiveAccessModifier. Jens, the method self.tokenized_like_conditions should not be public instead of private?

#6 Updated by Marius BALTEANU 9 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF