Closed mfrasca closed 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.
I guess new users (and myself) would remember it easier if we have:
=
reserved for equality, like
for the SQL like
operator, and contains
/has
for like %<value>%
.what else is covered by the code (search.py:390):
condition = lambda col: \
lambda val: mapper.c[col].op(self.cond)(val)
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.
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.
@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.
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.
domain search allows
contains
andhas
(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 withlike
? this way it is not possible to filter "starts with <value>".