After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 538203 - Incorrect parsing of search terms involving "-"
Incorrect parsing of search terms involving "-"
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: User Interface
git master
Other All
: Normal minor
: 1.x
Assigned To: Banshee Maintainers
Banshee Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-06-13 20:46 UTC by Chow Loong Jin
Modified: 2008-07-15 12:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log of performed SQL queries (2.27 KB, text/plain)
2008-07-06 21:35 UTC, Michael Kaiser
  Details
proposed fix (1.60 KB, patch)
2008-07-07 09:27 UTC, Michael Kaiser
none Details | Review
proposed fix (1.41 KB, patch)
2008-07-07 09:43 UTC, Michael Kaiser
needs-work Details | Review
proposed fix (1.46 KB, patch)
2008-07-13 21:05 UTC, Michael Kaiser
committed Details | Review

Description Chow Loong Jin 2008-06-13 20:46:19 UTC
Please describe the problem:
When a search filter such as "term1 -term2" is used, the result is as predicted, which is to include all entries which match "term1", and exclude all entries which match "term2". However, reversing the search filter to "-term2 term1" doesn't give the same result. Instead, the result is rather unpredictable. An example is "cascada -ready" and "-ready cascada". The former results in all Cascada songs appearing except "Ready For Love", whereas the latter results in just "Ready For Love" by Cascada appearing.

Steps to reproduce:
1. Open a media source
2. Type two terms, one preceded by a not operator.
3. Reverse the two terms
4. Observe the different results.


Actual results:
Incorrect parsing of the search terms for "-term2 term1".

Expected results:
"-term2 term1" should be identical to "term1 -term2".

Does this happen every time?
Yes

Other information:
Comment 1 Michael Kaiser 2008-07-06 21:32:43 UTC
I can reproduce this bug. Performing a search on "-term2 term1" yields all titles containing both term1 and term2. Searching for "-term2" however works as expected, only after entering the second search term, titles matching term2 appear. I am attaching an excerpt from an sql log showing the generated queries for searching "term1 -term2" and "-term2 term1".
Comment 2 Michael Kaiser 2008-07-06 21:35:03 UTC
Created attachment 114083 [details]
Log of performed SQL queries

SQL queries when searching for "term1 -term2" and "-term2 term1"
Comment 3 Michael Kaiser 2008-07-07 09:27:20 UTC
Created attachment 114102 [details] [review]
proposed fix

This patch to UserQueryParser.cs appears to fix the bug.
If ParseToken was called to parse an 'And' or 'Or' token while current_parent was pointing to a 'Not' node, it simply forgot to include this 'Not' node into the resulting parse tree. This patch makes ParseToken handle this case separately in order to guarantee a correct parse tree in all cases.
Comment 4 Michael Kaiser 2008-07-07 09:43:14 UTC
Created attachment 114103 [details] [review]
proposed fix

I realized I should simplify the code the moment I sent the first patch, sorry.
Comment 5 Bertrand Lorentz 2008-07-13 20:47:19 UTC
Please use spaces for indentation, instead of tabs.
Have a look at the HACKING file for more information.
Comment 6 Michael Kaiser 2008-07-13 21:05:45 UTC
Created attachment 114493 [details] [review]
proposed fix

reformatted patch
Comment 7 Gabriel Burt 2008-07-15 12:50:10 UTC
Thanks a lot Michael!  I committed this to trunk.