I think this is a bug but might be a feature request, up to you, but when you type in the autocomplete fieild, you Must get the capitalization of the name correct or you will not find the user, I think for accessibility and ease of use, this should be a no brainer, allow the user to type jim and Jim.

CommentFileSizeAuthor
#13 privatemsg_ilike.patch797 bytesnaheemsays

Comments

naheemsays’s picture

It's not case sensitive here. What database backend are you using?

berdir’s picture

PostreSQL's LIKE is not case insensitive..

naheemsays’s picture

Do you think it may be a good idea to use the function LOWER() or UPPER() to make it all as database agnostic as possible?

(I think that finction exists in postgres and mysql, but have no idea about others...)

litwol’s picture

i would like to avoid using this method as it is extremely slow because using LOWER or UPPER prevents using table indexes

berdir’s picture

Me too, but we can't avoid it, not in D6. Core is currently doing the same thing and will hopefully add lower-case fields for things like username and taxonomy terms.

user_load() is using lower() anyway, so we should be consistent.

litwol’s picture

If we are going to support case agnostic solutions then we should start caching people's names in a new table {uid, LOWER(name)} in hook_user_{$register|$edit|...} or something.

spydmobile’s picture

I understand the issues you face but I consider this a real usability issue, normal folks just dont understand why they have to type caps in one user lookup in drupal but not in another in the same site. I would rather take the performance hit than the usability hit, Just more pennies to add to my initial 2 cents... But I like the idea of a cache table as you have mentioned. I would be happy for anything that makes my users life easier.
F

spydmobile’s picture

Also, I am indeed a postgres shop and postgress does support upper as does php. so it can be done in the database or in the module.

naheemsays’s picture

is there some way to automagically switch to ILIKE for postgres?

If Mysql could also support ILIKE (which for it would be the same has LIKE...), things would be easier.

berdir’s picture

While we are working on it, you can easily change it with a simple hook, if you know a bit PHP:

See
http://blog.worldempire.ch/api/group/sql/1
http://blog.worldempire.ch/api/function/hook_privatemsg_sql_autocomplete...
http://blog.worldempire.ch/api/function/privatemsg_sql_autocomplete/1

Create a yourmodule_privatemsg_sql_autocomplete_alter hook and replace the LIKE in the first where part. And please post your hook here so that others can use it too, if they want.

Edit: BTW, PostgreSQL does support LOWER()

naheemsays’s picture

would an str_replace work?

Something like:

function mymodule_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
 $fragments = str_replace('LIKE', 'ILIKE', $fragments);

??

berdir’s picture

It should if you replace it in $fragments['where'][0].

naheemsays’s picture

Status: Active » Needs review
StatusFileSize
new797 bytes

ok, attaching a patch for the query builder that should solve this for pgsql - However I do not have pgsql installed so testing will have to be done by others.

spydmobile’s picture

I am on the road right now, but I will be back in the office and test this patch tomorrow and feedback here.... And thanks for speeding a solution through folks!
Franco

spydmobile’s picture

Ok, just hand bombed the lines into the module and installed in vannila d6, problem solved, thanks so much guys!!!

Franco

naheemsays’s picture

Title: Make TO: Auto complete case insensitive » Querybuilder: Make "LIKE" case insensitive on pgsql
berdir’s picture

Status: Needs review » Reviewed & tested by the community

Nice little patch that gets it working without loosing the performance on MySQL.

litwol’s picture

Aquote of dries' quote from http://lists.drupal.org/pipermail/development/2007-January/021942.html : Removal of ilike searches. Use lower() = lower() it is faster.

litwol’s picture

Status: Reviewed & tested by the community » Fixed

Committed. thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.