Modify

Opened 13 years ago

Last modified 2 years ago

#5650 new defect

The term 'key:' can only be the last term of a multiple AND search expression.

Reported by: adjuva@… Owned by: team
Priority: minor Milestone:
Component: Core Version: latest
Keywords: search dialog Cc:

Description (last modified by Woazboat)

In the search dialog:

The expression 'key1=* key2:' is a valid search expression and works.

When you switch the two terms surround the implicit AND you get get the logically equivalent expression 'key2: key1=*', but after pressing <enter> you got the error message 'Search expression is not valid: Unexpected token: <equals>'.

The error seems to be complex:

  • 'key2: | key1:' and 'key2:|key1:' works
  • '( key2: ) key1:' and '(key2:)key1:' works
  • 'key2: modified key1:' finds only elements, where the value of key2 contains 'modified'. It is equivalent to the expression 'key2:modified key1:'
  • 'key2: type:way key1:' is no valid expression. The error message is 'Unexpected token: <colon>'.

The whitespace after the first colon seems to be ignored. This explains all error messages and the wrong behavior in the "modified" case.

When I look in the source code, I think the error should be fixed in action/search/PushbackTokenizer.java in the Method nextToken(). After the token <colon> a token <key> with an empty string should be returned, when the colon is followed by a whitespace.

To reach this the following lines could be inserted before 'return Token.COLON;':

if (c != -1 && Character.isWhitespace(c)) {
    getChar()
    currentText = "";
    currentToken = Token.KEY;
}

This patch is not tested.

Since 'key2:' can easily be replaced by 'key2=*' or '( key2: )' this error is no blocker for complex expressions, but new user would be astonished and irritated.

Attachments (0)

Change History (1)

comment:1 by Woazboat, 2 years ago

Description: modified (diff)

The whitespace after the first colon seems to be ignored.

This is indeed the cause of this bug. The search expression key: foo bar is read as key:" foo" AND bar instead of the expected key: AND foo AND bar

key:"" can be used as a workaround.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to adjuva@….
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.