Bauble / bauble.classic

this is how Bauble and Ghini both started
GNU General Public License v2.0
10 stars 34 forks source link

'<domain> like <value>' matches '%<value>%' #161

Closed mfrasca closed 9 years ago

mfrasca commented 9 years ago

domain search allows contains and has (in the source code I did not find a difference), so you can filter all objects containing the substring in the searched fields. but why does it also look for a substring when searching with like? this way it is not possible to filter "starts with <value>".

brettatoms commented 9 years ago

I can't remember why its like this but in a domain search = is like without the %<value>%. So you should be a able to do genus = Max% to get a startswith.

mfrasca commented 9 years ago

I guess new users (and myself) would remember it easier if we have:

what else is covered by the code (search.py:390):

        condition = lambda col: \
            lambda val: mapper.c[col].op(self.cond)(val)
brettatoms commented 9 years ago

I think I did it that way since a domain search was kind of a wildcard search anyway geared more for non-technical people that wouldn't be familiar with SQL-esque terms like like, contains and has. Also with a domain search you could be searching across multiple columns on a table so there's not really a one-to-one mapping for searching a column or even a specific table. So a domain search would be more for narrowing down search results rather than trying to get an exact subset of result like a query search might be used

More advanced users could then do a query search for more advanced and specific search. At least that's what the original intention was.

mfrasca commented 9 years ago

just a note about something initially a bit surprising: if you look for »genus = Cyclo%« (but this happens also if you ask for »genus where genus like 'Cyclo%'«), you will get also the genera which are the accepted name for a genus matching your query. it's not immediately obvious why this happens, until you look at the synonyms section in the info pane.

mfrasca commented 9 years ago

@RoDuth, @smbantjes, @sehrgut, @felipead87: what do you think of this one? I prefer different semantics for different terms, so separate like from contains, and to keep = for equality. but I'm not a user and I'd like to collect more opinions.

sehrgut commented 9 years ago

I definitely would expect "like" to match a SQL LIKE clause. If you're not passing it straight through to SQL, but instead running your own pattern matcher (I haven't looked at that part of the code), I might suggest an operator that's both more obvious to less-technical users, and obviously not LIKE to technical users: matches, maybe?

I guess my vote would be that like should directly become a SQL LIKE pattern. Any alternative matching behaviour I'd prefer attached to a different operator.

mfrasca commented 9 years ago

in particular: https://github.com/Bauble/bauble.classic/blob/f45d1b0f84cff46763ecbfab996a53cd2daa6977/bauble/test/test_search.py#L337