jpahullo / moodle-tool_mergeusers

Merge users script for Moodle

Home Page:https://moodle.org/plugins/view.php?plugin=tool_mergeusers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search without case sensitive way

lcaylat opened this issue · comments

Hi,
We need to be able to search for users in a case-insensitive way in the merge users plugin, like in the Moodle users search.
Is it possible to modify your plugin in this direction?
Thanks in advance.
Regards.

Hi @lcaylat ,

It depends on your database collation.

In our institution, as stated in the Moodle standards, we use a MySQL server with a collation case insensitive, so that looking for "User" or "user" produces the same results. So, in the end, this is something transparent for the plugin.

Which database and collation are you using? Is your database with the correct collation for your database type?

However, I agree that search should be case insensitive by default.

I leave this issue open for a while, waiting for your feedback.

Jordi

Hi @jpahullo,
We currently use a PostgreSQL database which is therefore case sensitive.
On PostgreSQL, the ILIKE command allows you to search in a case insensitive manner. Please note this command does not exist on MySQL.
For example: select * from mdl_user mu where mu.username ilike 'EduN%';
A possibility of modifying the plugin would be to make a case disjunction depending on the base type to use ILIKE for PostgreSQL.
I hope you can take into account this need for the plugin to work with all kinds of databases.
Regards.

Thanks @lcaylat for your feedback.

It will require from me to look for installation requirements on other database types, like PostgreSQL or Oracle, to check which collations are exposed to be used on Moodle installation. Never checked. But it seems to me strange that for MySQL/Mariadb it is set by default to a "case insensitive" collation and not for the rest (maybe due to collation types on other database types).

However, I do not want to use specific SQL keys and terms specific for PostgreSQL or others. I would rather prefer to be agnostic of the underlying database type, using standard SQL.

So, definitely, I leave it open till analysing collation types for PostreSQL and Moodle requirements for it, and also for Oracle. It would be nice if you could provide in this issue the collation type you are using within the moodle database (the default one) and tables (they may differ from the database one). Database server default collation my differ too, and it is not necessary to know for this purpose.

By the way: on MySQL it it possible to run some setup with SQL statements during the connection phase on the config.php. Maybe it is also possible to do it for PostgreSQL, so that the connection collation is case insensitive, and all works as expected and transparently. Could you look for it and give it a try on some testing environment?

Thanks,

Jordi

Thanks @jpahullo for that answer.
After thinking about it, I realize that Moodle's native features already know how to perform this case-insensitive search.
In the /admin/user.php page, you can search without worrying about upper/lower case. Wouldn't it be wise to take inspiration from this code or the associated library?
I am not a developer and therefore I cannot go further into the investigations but I agree that the solution does indeed exist without conditioning the base type.
Thank you again for your attention to this issue.