The currentString Filter in Views is limited to being applied to the WHERE clause, which effectively renders the "OUTER" join as an "INNER" join once a condition is applied to any joined table. There are many cases where it is desirable to apply conditions to a related field, but to also show a NULL record if no relation exists, that is, to set conditions on the ON clause as opposed to the WHERE clause.

Proposed resolution

Add an option to the configuration of Field Comparison Filters to select the target of the filter condition, either "WHERE" or "ON". Expand class "views_handler_filter_string" to add the join "extra" if "ON" is selected. If "WHERE" is selected, use default "->add_where_expression()".
Make WHERE as the default to preserve behavior of all existing views.

Remaining tasks

  • Initial testing
  • Add support for query location in all comparison types in (eg op_starts(), op_ends(), ...):
    • op_equal
    • op_contains
    • op_word
    • op_starts
    • op_not_starts
    • op_ends
    • op_not_ends
    • op_not
    • op_shorter
    • op_longer
    • op_regex
    • op_empty
  • Modify field selector to prevent base_table properties to be used as RIGHT fields when ON is selected.
  • Insure that filter order insures that fields are not used in an ON clause before their table is added.
  • Add test bot tests
  • Wider testing by community.
  • Insure compatibility with Import/Export functionality to migrate Views among installs.

User interface changes

Add drop-down selector for "Condition Location", with options "WHERE" (default) and "ON".

API changes


Data model changes

The addition of a single configuration option "op_location" for Views that use this filter.

Members fund testing for the Drupal project. Drupal Association Learn more


robertwb created an issue. See original summary.

robertwb’s picture

robertwb’s picture

Status: Active » Needs review
robertwb’s picture

Issue summary: View changes
robertwb’s picture

Status: Needs review » Needs work
robertwb’s picture

Issue summary: View changes
Status: Needs work » Needs review
4.67 KB

Added ON clause support for op_starts(), op_contains(), op_not_starts()

robertwb’s picture

Issue summary: View changes

Export settings verified.