I've been helping with a site that is using CCK and Views. The users, as many users are wont to be, aren't terribly careful about proper word case. When I expose a filter ("contains") and have them enter, for example, "foo" it is not finding nodes with "Foo" in them and vice versa. Is this the way it is supposed to be? I hope not.

Comments

nancydru’s picture

??

merlinofchaos’s picture

Category: bug » feature

Yes, database searches are case sensitive by default. It causes additional load to convert everything to upper/lower case prior to matching, and these searches are pretty slow as it is.

You can write additional filters to get non case sensitive searches, but this isn't a bug. At best it's a feature request.

mooffie’s picture

Category: feature » bug
Status: Active » Postponed (maintainer needs more info)

>
> Yes, database searches are case sensitive by default.

Are you sure?

CCK uses the 'views_handler_filter_like' operator for its string filter. And this function, which resides in 'views.module', wraps every string in the SQL with 'UPPER()'.

Here's a snippet from the function:

function views_handler_filter_like(...) {
      ...
      switch ($filter['operator']) {
        case 'contains':
          $query->add_where("UPPER(%s) LIKE UPPER('%%%s%%')",
            $field, $filter['value']);
          break;

Nancy, the same code, and therefore the same SQL, is used for filtering by node title. Does filtering by node title is case sensitive too, on your system?

(Is it possible your DB uses the 'utf8_bin' collate?)

nancydru’s picture

This is not my site; I'm just helping. But yes, I am sure this is happening. I don't filter on title, so I can't say whether it's doing it on the title.

Collation:
collation_connection utf8_general_ci
collation_database latin1_swedish_ci
collation_server latin1_swedish_ci

php: 4.3.11
MySql: 4.1.21

mooffie’s picture

Well, I can only suggest two things:

1. Do SHOW FULL COLUMNS FROM table-name; and verify that you see 'utf8' in the collation column. (If you're using phpMyAdmin, this info is in each table overview screen.)

2. Do SELECT UPPER(column-name) FROM table-name; and see if there's something strange there. That is, if there are lowercase letters that got converted wrong.

rocknet’s picture

It is my site that Nancy has been working on and this filter problem has appeared. The strange thing is that two of the filters work fine for lower case and upper case. They return a positive match regardless of what case the first letter is. Just what I would expect.

However, the third and subsequent filters do not work as expected. They are case sensitive which will cause confusion for my users, who can't be expected to know that they should start their search terms with an upper case letter.

These symptoms would indicate that the system is capable of working, but does not.

mooffie’s picture

It would be helpful to see the SQL query that is generated. The 'devel' module lets you see all the queries sent to MySQL. Please install it and paste here the query.

merlinofchaos’s picture

It may be that an individual filter is case sensitive; you must tell us which filters you're actually using.

mark matuschka’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

I had the same problem.
Fixed by patch at http://drupal.org/node/165611.