Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is a bunch of information about how to do table joins in the Advanced Help for Views 7, topic "api-tables.html", which is not in hook_views_data() for Drupal 8.
This is fairly essential information and needs to be added.
At least, I needed it today to work on #2218065: Need to join fields to the entity field data tables, not entity tables, or filtering increases number of results, so I think it's essential today. :)
I'll make a patch...
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff.txt | 7.49 KB | jhodgdon |
#14 | 2321995-14.patch | 8.27 KB | jhodgdon |
Comments
Comment #1
jhodgdonSome notes:
- in that other issue we're adding the ability to use 'left_field' instead of 'value' in "extra" in joins
- I do not think %alias works in "extra" in joins as documented in the Advanced help. Use 'left_field' instead.
Comment #2
jhodgdonHere's a patch. It is not actually true until #2218065: Need to join fields to the entity field data tables, not entity tables, or filtering increases number of results and its change adding the 'left_field' syntax to 'extra' gets in. I guess we could roll it into that other patch, but even if that never gets in we should I think document the rest.
Comment #6
jhodgdonHere's a new patch. Since no one reviewed this yet, I did not bother with an interdiff. I hope that's OK.
Comment #10
jhodgdonAmazingly enough, this patch still apparently applies. Would be nice to get a review sometime...
Comment #11
dawehnerLooks pretty solid for me.
Should we replace the 'extra' here with 'additional'?
Comment #12
jhodgdonSure. Fixed this in two places.
Uck. Due to patch fuzz, interdiff didn't work. Anyway I only changed two comments to say:
and everything else is the same.
Comment #13
dawehner+1 for the general part. What about adding an example how the resulting SQL query would look like then?
Comment #14
jhodgdonOK. The previous join stuff didn't have an example of the SQL, so I added that to both parts of the docs.
And... well this example doesn't work any more, because the base table for joining to nodes is now node_field_data, not node. So I made up a fictitious example instead.
And I noticed the comments on the first join information were saying 'node' but the join was to 'node_field_data' ... wasn't fully updated.
So there are a few diffs.
Comment #15
dawehnerGreat observation!
IMHO this is a good step forward, so let's get it in.
Comment #16
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!