Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Here are the files.

The tests aren't passing at the moment.

dawehner’s picture

Status: Needs review » Needs work

additional information:

[23:14] <chx> and that UPPER crap is no longer necessary
[23:15] <chx> Drupal defines LIKE as case insensitive.
[23:15] <chx> read http://api.drupal.org/api/drupal/includes--database--pgsql--database.inc/function/DatabaseConnection_pgsql::mapConditionOperator/7 for more
[23:16] <chx> just make sure you use LIKE as an operator
bojanz’s picture

So, do we kill the "case sensitive" option completely?
We already say "MySQL might ignore case sensitivity.", so if now postgres is the same I'm not sure there's much we can or should do.

Also,

+  function variable_name() {
+    return ':' . __CLASS__ . __FUNCTION__ . $this->options['id'];
+  }

Bluurgh. Took me a few seconds to realize that this is actually generating a placeholder. Should it then find a home in views_plugin_query_default?
Since we had the same placeholder problem in arguments, would be good to solve it across the board.

dawehner’s picture

Cool. So we can drop this feature in general.
-------
My idea here was to generate a unique but somehow readable placeholder.

We could use a counter-placeholder-method in views_plugin_query_default , right.

bojanz’s picture

The placeholder trick is really neat. We just need to move it to views_plugin_query_default, rename it, give it some docs, and make sure it works in all situations (will it work for those arguments in subqueries? We have some complicated queries...)

I'll reroll the patch for case sensitivity.

dawehner’s picture

In contrast to ***FOO*** this is a real dbtng placeholder, so if this doesn't work this is a core bug, or?

Sadly this nice trick with __FUNCTION__ and __CLASS___ don't work in query_default, but it's okay.

bojanz’s picture

FileSize
4.98 KB

Sadly this nice trick with __FUNCTION__ and __CLASS___ don't work in query_default, but it's okay.

Yeah, I overlooked that little fact.

Leaving the topic alone for now then, and just providing a reroll.

Btw, shouldn't op_contains() get the same db_like() treatment?

I'll take another peek at this issue when I come home tonight, my brain is refusing to boot up at the moment.

bojanz’s picture

FileSize
5.1 KB

Better patch (last one left one instance of 'case').
Note that we need to fix views_handler_argument_string the same way.

dawehner’s picture

Status: Needs work » Needs review
FileSize
9.28 KB

* renamed variable_name to unique_placeholder
* moved the method to the views_handler class
* fixed the argument string
* fixed op_contains

A full test is somehow required here :)

dawehner’s picture

After quite a lot of work a full test is added.

This test passes with the patch above.

bojanz’s picture

Awesome.

Was wondering whether we should add a counter to the unique_placeholder() function, so that we can use it multiple times from the same function (which will surely be needed).
In general, I'm having mixed feelings about unique_placeholder in views_handler. On one side, it makes debugging easier, since I can easily see where the placeholder is coming from. On the other hand, it's a dbtng specific function in a handler, code that should generally be in the specific query plugin.

dawehner’s picture

FileSize
10.64 KB

So here is an update.

dawehner’s picture

FileSize
10.41 KB

New version.

bojanz’s picture

   var $placeholder_counter = 0;
 
+  /**
+   * Provides the current used placeholder base.
+   */
+  var $placeholder_base = 'default';

Kill both, they are unused

dawehner’s picture

FileSize
11.17 KB

Removed placeholder_count, too.

Added views_handler::placeholder based on the latest idea.

Tests are .... passing


11 passes, 0 fails, 0 exceptions, and 22 debug messages

This aren't a lot of passes for this big amount of code.

bojanz’s picture

Status: Needs review » Fixed

http://drupal.org/cvs?commit=470112

A follow-up will be to convert all code to use the new placeholder method.
Best done after add_where_expression() lands (or simultaneously, since it touches the same code)

Status: Fixed » Closed (fixed)

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