ViewsJoin in D8 has an advertised behavior of the JoinPluginBase to permit operators other than '=' in the relationship:

# -- excerpted from core/modules/views/src/Plugin/views/join/JoinPluginBase.php

 * Here are some examples of configuration for the join plugins.
 *
 * For this SQL:
 * @code
 * LEFT JOIN {two} ON one.field_a = two.field_b
 * @endcode
 * Use this configuration:
 * @code
 * $configuration = array(
 *   'table' => 'two',
 *   'field' => 'field_b',
 *   'left_table' => 'one',
 *   'left_field' => 'field_a',
 *   'operator' => '=',
 * );

Currently, the code uses '=' in all cases:

    $condition = "$left_field = $table[alias].$this->field";

To be equivalent to the advertised behavior in D8, it should allow the relationship def to specify an operator:


    $operator = !empty($this->definition['operator']) ? $this->definition['operator'] : '=';
    $condition = "$left_field $operator $table[alias].$this->field";

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

robertwb created an issue. See original summary.

robertwb’s picture

robertwb’s picture

Issue summary: View changes
robertwb’s picture

Status: Active » Needs review
Chris Matthews’s picture

The 2 year old patch in #2 to handlers.inc applied cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.

klonos’s picture

This patch has a coding standards violation, where there's two lines of code into one. I would re-roll it properly, but unsure if we're still doing patches or have switched to using merge requests in https://git.drupalcode.org/project/views/-/merge_requests instead (which would be most convenient TBH).

I've also seem to have lost the ability to change issue properties/metadata. Someone will need to change this to "needs work".

DamienMcKenna’s picture

Status: Needs review » Needs work

You haven't lost the ability to change issue meta data, but you might have misplaced it.

Yes the patch needs to be fixed.