Needs work
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Mar 2009 at 13:38 UTC
Updated:
15 Jun 2011 at 13:35 UTC
Jump to comment: Most recent file
Comments
Comment #1
thekevinday commentedbump to latest version
Comment #2
merlinofchaos commentedHey there's a patch here. SEtting to proper status so it'll get into my review passes.
Sorry this got lost.
Comment #3
merlinofchaos commentedOk, a couple of minor comments here.
1) lower( should be LOWER( since we always put database keywords in upper case.
2) "Ignore Case" should be "Ignore case"
3) MySQL is case insensitive by default, and that's 90% of our users, so we should tell the users they don't need to check this since turning it on could reduce performance.
Comment #4
thekevinday commentedThen try this one out.
Comment #5
thekevinday commentedThere was a mistake where LOWER was added in an area where it should not have been added.
Please review this new patch.
Comment #6
dawehnerlooks fine
Comment #7
merlinofchaos commentedApplied to 6.x branches; needs work for 7.x still due to dbtng.
Comment #8
thekevinday commentedI have more recently been wondering which of the following ways is the better way to do this:
1) use the SQL LOWER as done by this patch
2) use the php strtolower function instead
Which one would have better performance?
Which one would have better scalability?
The php strtolower has the advantage of consistency and not having to worry about differences between the different supported databases.
But...the disadvantage, might that be character encoding issues (ascii, utf8, iso8859-1, etc..)?
Comment #9
dawehnerMysql is the suggested way to do this, because you can use it to filter/sort do anything with it. With php you have less possiblites.
Comment #10
dawehnerUpdate patch.
So what's the problem
This code produces the sql
But when adding '' i get a
Comment #11
thekevinday commentedHere is where I suspect the problem happens.
Perhaps MySQL does not like the query
LOWER('').I am changing the code to add a php
empty()functional call as an additional check before adding the SQLLOWER()function.If the patch has been applied as mentioned in #7, then should a bug report be opened for the 2.x version?
Also, this patch applies the SQL
LOWER()function call to the field name, is this necessary or can the field name be guaranteed lower case?Comment #12
dawehner@thekevinday
This is drupal7, the sql code needs something different here. You cannot use direct sql like LOWER() without any additional problems :(
Comment #13
dawehnerBased on #12
Comment #14
thekevinday commentedI have looked all over the drupal 7 database api, I cannot seem to find where to call functions against specific fields.
Either I need to be pointed in the right direction or this may not be doable until the drupal 7 database api fully supports the SQL standard. (namely, sql functions)
Comment #15
thekevinday commentedI noticed that the date module does the following:
So then does that mean we could do something like this?
Comment #16
thekevinday commentedI seem to have forgotten about this patch up until I needed it again. Here is the updated coded.
Apparently, views is already adding their own implicit SQL (namely
IN()).I used that as an example on how to properly implement adding
LOWER()with the d7 dbapi.I also noticed that views_plugin_argument_validate_taxonomy_term should support case insensitive searches as well.
Please Review this patch.
Comment #17
merlinofchaos commentedDoes this really work? I have my doubts that it works that way.
Comment #18
thekevinday commentedI was uncertain of how placeholder was handled in this case.
I know for a fact the following does not work:
IN(LOWER("a", "b", "c"))Instead the following does work:
IN(LOWER("a"), LOWER("b"), LOWER("c"))I just don't know how placeholder works in this case.
It seems a little odd for IN to be used with only one argument, so I am going to believe that placeholder is an array.
So then how do we handle properly wrapping the translated placeholder to produce the second example above?
Comment #19
dawehnerWell you could need to construct the string and use single placeholders foreach argument.
Update status.
Comment #20
merlinofchaos commentedIt's an array, and it's a DBTNG thing. I don't honestly know how to handle something like that using DBTNG.
Comment #21
thekevinday commentedI believe I may have to manually expand that array.
The following urls are of importance:
- http://drupal.org/node/310072#placeholder-arrays
- http://api.drupal.org/api/drupal/includes--database--query.inc/interface...
- http://api.drupal.org/api/drupal/includes--database--select.inc/function...
- http://api.drupal.org/api/drupal/includes--database--select.inc/interfac...
Now the trick is expanding it properly.
If I expand the placeholders, then I assume I need to expand the actual arguments?
Is this necessary, or is it possible to do a db_select with the following snippet:
.. "SELECT * from node where nid = :nid_1 OR nid = :nid_2", array(':nid' => array(501, 502)) ..The QueryPlaceholderInterface::nextPlaceholder sounds like the class & function to use.