Active
Project:
Data
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 May 2014 at 23:12 UTC
Updated:
16 Jun 2014 at 20:21 UTC
Jump to comment: Most recent
While working on a project to join an entity table to a data table on one of the entity field values, I came across this comment at http://cgit.drupalcode.org/data/tree/data.views.inc?h=7.x-1.x#n58 :
// @todo: See if left table has other tables it is linked to and link
// all the way to the leftmost table.
@alex_b - any leads on how to do that? I'd take a stab at it!
Comments
Comment #1
bc commentedComment #2
bc commentedRelated: rejected support request #897814 and https://drupal.org/node/898496 as well
Comment #3
bc commentedAs a stopgap solution, I am using hook_views_data_alter to add a join to any view that includes a certain field: https://github.com/ESDet/esdportal_str/blob/7.x-1.x/esdportal_str.module...
This could be generalized in data.views.inc somehow...
Comment #4
joachim commentedWhy not just use a taxonomy term reference field?
Comment #5
bc commentedJoachim, do you mean I should add an entity reference to the data table?
In my case, data tables are non-modifiable. Also, based on alex_b's comment it looks like there are other cases where this functionality comes into play.
Comment #6
joachim commented> Joachim, do you mean I should add an entity reference to the data table?
I don't mean a new database field to your data table, but a FieldAPI field. It looks like you've already done that -- is field_data_field_bcode not a FieldAPI table? If it's storing taxonomy term IDs, then you are better off using a proper refererence field.
Comment #7
bc commentedfield_data_field_bcode is a FieldAPI field used by a taxonomy term entity type, hence the two joins.
Data table has a column "bcode", which can be joined with the FieldAPI field_data_field_bcode table's field_bcode_value column, which can then be joined via field_data_field_bcode.entity_id to a taxonomy term
Comment #8
joachim commentedAh, I get it.
You're much better off using an entityreference field, either from your Data entity to the taxonomy terms, or the other way round. You'll get the relationships in both directions in both cases.