New TracQuery match operator for "contains the word" would be useful
|Reported by:||Owned by:|
|Severity:||minor||Keywords:||query keywords exact match|
In a number of situations, it's useful to be able to search field values that contain a certain word, not just a certain string (as
~= does). The distinction is essentially a word boundary regex versus an all-inclusive regex. That is, I'd like to be able search like this:
\b is a "word boundary" as defined by the PCRE standards. Right now, using
~=, I can only search like this:
The most pressing use case for such a facility (at least for my projects) is support for "subticket keywords", an extremely flexible technique of associating one ticket with another by using the TracLinks conventions in the keyword field.
For example, to associate a new ticket as a "subticket" of ticket:13, I place
#13 in its keyword field. Currently, this can later be extracted with a TracQuery such as
[[TracQuery(keywords~=#13)]] however this incorrectly matches
#131, and so on. Thus, a word boundary match operator was suggested by Remy Blank later in the same thread.
At first blush, it seems that the TracQuery "mini language" is actually implemented with simple ANSI SQL-based wildcards, which makes implementing word boundary matches non-trivial. I'd imagine one might have to wrap a call to Query.execute that catches the results of a
~= query and then filters these results further (possibly with a decorator?).
Change History (8)
comment:5 Changed 8 years ago by
|Keywords:||keywords exact match added|
|Milestone:||triaging → next-major-0.1X|
|Priority:||normal → low|
|Severity:||major → minor|