Ticket #9731 (closed defect: invalid)

Opened 4 months ago

Last modified 4 months ago

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

Reported by: jbeilicke Assigned to: 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

multi-fields.diff (12.6 kB) - added by jbeilicke on 01/26/12 11:40:21.

Change History

01/26/12 11:40:21 changed by jbeilicke

  • attachment multi-fields.diff added.

(follow-up: ↓ 2 ) 01/29/12 19:46:50 changed by cmc

  • status changed from new to closed.
  • resolution set to invalid.

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.

(in reply to: ↑ 1 ; follow-up: ↓ 3 ) 01/29/12 20:40:09 changed 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. :)

(in reply to: ↑ 2 ; follow-up: ↓ 4 ) 01/29/12 21:06:40 changed 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.

(in reply to: ↑ 3 ) 01/30/12 11:51:45 changed 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/Change #9731 (Custom queries broken when using "contains" with a multi-select custom field)




Change Properties
Action