Modify

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#9731 closed defect (invalid)

Custom queries broken when using "contains" with a multi-select custom field

Reported by: jbeilicke Owned by: cmc
Priority: normal Component: MultiSelectCustomFieldsPatch
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

Attached please find a modified version of the original patch that fixes the mentioned issue in Trac 0.12. The bug in ticket/query.py line 545 lead to wrong database results, due to a pipe right before the last percentage:

Original patch:

value = '%' + value + '|%'

Modified version:

value = '%' + value + '%'

Attachments (1)

multi-fields.diff (12.6 KB) - added by jbeilicke 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by jbeilicke

comment:1 follow-up: Changed 2 years ago by cmc

  • Resolution set to invalid
  • Status changed from new to closed

That is not correct. All multi-select values should end with a pipe. Hence, '%' + value + '%' may actually return incorrect result.

Imagine if options were 'Dog' and 'Dog Park'. If you searched for 'Dog', a ticket with 'Dog Park' (in the database, 'Dog Park|') would come up with your proposed change. Instead, if you search for '%Dog|%', no Dog Park entries will be returned.

comment:2 in reply to: ↑ 1 ; follow-up: Changed 2 years ago by jbeilicke

Replying to cmc:

That is not correct. All multi-select values should end with a pipe. Hence, '%' + value + '%' may actually return incorrect result.

You are right, of course. Quite obvious, but I didn't see this. Thanks for the clarification. I will revert my patch and check again why the queries with multi-selects are not working as expected. :)

comment:3 in reply to: ↑ 2 ; follow-up: Changed 2 years ago by cmc

Replying to jbeilicke:

Replying to cmc:

That is not correct. All multi-select values should end with a pipe. Hence, '%' + value + '%' may actually return incorrect result.

You are right, of course. Quite obvious, but I didn't see this. Thanks for the clarification. I will revert my patch and check again why the queries with multi-selects are not working as expected. :)

Mind you, this patch was originally written for 0.11 and I haven't worked on the 0.12 version for a year. I wouldn't be at all surprised if there was a bug somewhere else ;) Are the fields savings with pipes? If you're converting an existing field over to use multi-select, you'll need to append a pipe to each value.

comment:4 in reply to: ↑ 3 Changed 2 years ago by jbeilicke

Replying to cmc:

Replying to jbeilicke:

Replying to cmc:

That is not correct. All multi-select values should end with a pipe. Hence, '%' + value + '%' may actually return incorrect result.

You are right, of course. Quite obvious, but I didn't see this. Thanks for the clarification. I will revert my patch and check again why the queries with multi-selects are not working as expected. :)

Mind you, this patch was originally written for 0.11 and I haven't worked on the 0.12 version for a year. I wouldn't be at all surprised if there was a bug somewhere else ;) Are the fields savings with pipes? If you're converting an existing field over to use multi-select, you'll need to append a pipe to each value.

That is the case: I have to append the pipe. Thanks again.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from cmc. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.