I updated to the views 7.x-3.0-alpha1 - missing checkbox "Sensitive" in the filter on the field "Title. "
In the filter on other fields, it is also missing.

I have a PostgreSQL database and if the user typed text in another case the filter does not work.

PS In 7.x-3.x-dev 2011-Jan-1915 checkbox is also missing.

CommentFileSizeAuthor
#7 1029534.patch2.66 KBbojanz

Comments

fexmusicmutuz’s picture

Help me, please!!!

bojanz’s picture

Status: Active » Closed (works as designed)

Case sensitivity has been removed. All filters are assumed to be case insensitive. This is due to Drupal 7 architecture.

Also, please don't bump your issues. It's rude.

bojanz’s picture

Title: missing checkbox "Sensitive" in the filter » PostgreSQL case sensitivity in filter
Version: 7.x-3.0-alpha1 » 7.x-3.x-dev
Status: Closed (works as designed) » Active

I have a PostgreSQL database and if the user typed text in another case the filter does not work.

This needs to be confirmed (it should not happen)

fexmusicmutuz’s picture

LIKE statements are case sensitive in postgresql

bojanz’s picture

The Drupal 7 DB Layer defines LIKE as ILIKE for PostgreSQL. But maybe we are doing our own thing somewhere...

fexmusicmutuz’s picture

The Drupal 7 DB Layer defines LIKE as ILIKE for PostgreSQL. But maybe we are doing our own thing somewhere...

I think the DB Layer will not help here:

  function op_starts($field) {
    $placeholder = $this->placeholder();
    $this->query->add_where($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%'), 'formula');
  }
bojanz’s picture

Status: Active » Needs review
StatusFileSize
new2.66 KB

Summary:
MySQL and SQLite specify LIKE as case-insensitive.
However, PostgreSQL specifies LIKE as case-sensitive, and provides ILIKE that works like the MySQL / SQLite variants.
Drupal's DB layer knows how to handle it. Which doesn't matter for us because we aren't using it in this case :P
And there's no reason I can see for us not to use it.

Attaching a patch that uses Drupal's db layer for the LIKE operations. All string filter tests still pass.

I did a checkout of Views from August, and while the code was similar to the proposed patch, it didn't use db_like() and it still used the unneeded UPPER trick. So I think we're good here (going with the proposed approach)

P.S. As a guide for db_like() usage I'm reading http://drupal.org/node/683736. Plus we have instances in our codebase where are using LIKE as the operator, and db_like is there.

dawehner’s picture

Status: Needs review » Fixed

This original patch failed for op_equal

  function op_equal($field) {
    $this->query->add_where($this->options['group'], $field, db_like($this->value), $this->operator());
  }

The tests showed one failure.

Fixed this small part and the test seems fine again.

Status: Fixed » Closed (fixed)

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