Problem/Motivation
While working on #2321721: Provide a views relationship for each dynamic entity reference field when I tried to add extra condition(target_type = $entity_type_id) on left table it started giving SQL syntex error. After some research I discovered that JoinPluginBase::buildJoin() doesn't take left table field and value as an extra condition in join.
Proposed resolution
Allow adding left table field and value as an extra condition in join.
Remaining tasks
Reveiw the patch
User interface changes
None
API changes
JoinPluginBase::buildJoin() allows to add left table field and value as an extra condition in join.
array(
'left_field' => 'status',
'value' => 0,
'numeric' => TRUE,
),
Beta phase evaluation
Comments
Comment #2
jibranComment #3
dawehnerSorry but this is not a bug, but rather a feature/task.
Awesome!
Comment #4
alexpottThis issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.
Comment #5
dawehner@alexpott
Automated answer?
Comment #6
jibranThanks @dawehner for the IS update :)
Comment #7
alexpott@dawehner unfortunately
Is not true. There is no agreement that internal refactors are unfrozen.
Comment #8
jibranIt is not re-factoring it just adds the missing option which should be already there that is why I reported it as bug report. In other words it is only api addition to incomplete api.
This is a sample query for ER
This is a sample query for DER
You can see it only adds
AND entity_test__field_test.field_test_target_type = 'entity_test'which imho I should be able to do with views while defining relationship.Hope this helps.
Comment #9
jibranIn IRC @alexpott said
Relationship module is already working on using DER as backend for 8.x branch. See #2315599-2: Consider Dynamic Entity Reference for storage needs. 9,373 sites currently report using relation module in D7. Is this a concrete use case from contrib?
Please let me if you still need anything else and if you are still not convinced please postpone this and move to 8.1.x.
Thanks.
Comment #10
jibranCan I get RTBC here in the light of #2407587-23: Allow multiple target entity types in the entity reference field?
Comment #11
dawehner... It would be so great if you could add an example at the top of the class, which would explain how to join on a field with a given value.
You added the appropriate test coverage, so things are nice, and nearly RTBC.
Comment #12
jibranThanks for the review. I have added some docs. Do you think we need change notice as well?
Comment #13
jibranAlso related #2410011-5: add a views_data handler
Comment #14
dawehnerWe have some good docs, we have some tests
Comment #15
alexpottIt feels like we should also be testing the
$join_info['arguments']contains the expected values.Comment #16
jibranSeems a fair point. We are already doing in previous tests but added new assert for this case as well.
Comment #17
dawehnerThe feedback from alex got adressed
Comment #18
alexpottI'm committing this because it helps contrib modules do more with core and is not disruptive. Committed 155a314 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Comment #21
tunicThis issue shoud be backported to D7. There's a separate issue with a patch tests in green: #2642100: views_join doesn't allow extra conditions on left table.