Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#9731 closed defect (invalid)

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

Reported by: Jan Beilicke Owned by: CM Lubinski
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 Jan Beilicke 12 years ago.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Jan Beilicke

Attachment: multi-fields.diff added

comment:1 Changed 12 years ago by CM Lubinski

Resolution: invalid
Status: newclosed

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 ; Changed 12 years ago by Jan Beilicke

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 ; Changed 12 years ago by CM Lubinski

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 12 years ago by Jan Beilicke

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain CM Lubinski.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.