Problem/Motivation
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 views_handler_filter_string.inc (eg op_starts(), op_ends(), ...):
op_equalop_contains- op_word
op_startsop_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
None.
Data model changes
The addition of a single configuration option "op_location" for Views that use this filter.
Comment | File | Size | Author |
---|---|---|---|
#9 | views-allow_string_filter_to_be_attached_to_on-2662910-9.patch | 4.77 KB | Andrew Answer |
| |||
#6 | views-string-filter-on-clause-2662910-06.patch | 4.67 KB | robertwb |
| |||
#2 | views-string-filter-on-clause-2662910-02.patch | 2.74 KB | robertwb |
|
Comments
Comment #2
robertwb CreditAttribution: robertwb commentedComment #3
robertwb CreditAttribution: robertwb commentedComment #4
robertwb CreditAttribution: robertwb commentedComment #5
robertwb CreditAttribution: robertwb commentedComment #6
robertwb CreditAttribution: robertwb commentedAdded ON clause support for op_starts(), op_contains(), op_not_starts()
Comment #7
robertwb CreditAttribution: robertwb commentedExport settings verified.
Comment #8
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 2 year old patch in #6 to views_handler_filter_string.inc does not apply to the latest views 7.x-3.x-dev.
Comment #9
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedPatch rerolled.