Problem/Motivation
When field names a too long, the actual 'real table' used for field storage is a hashed snippet of the actual field name. E.g. field_collection_item_5c4820gfrd (choosing this as it's a good example of an entity with a long name, which amplifies the likelihood of the problem).
Trying to create a relationship on this field, for example an entity reference field, will result in a lot of 'table not found' sql errors.
Proposed resolution
After some digging it ended up being a problem when HandlerBase::getTableJoin() tries to create a join to add to the query for the relationship. The table join data that would be used is not defined for fields, so it just relies on the views table name (which is the regular field name (not shortened)). If we add join table items for the actual table, views will use this in the joins and peace is restored.
Remaining tasks
Tests
User interface changes
N/a
API changes
Table key added to join table data for field views data.
Data model changes
N/a
Comment | File | Size | Author |
---|---|---|---|
#4 | interdiff-2755043-4.txt | 853 bytes | damiankloip |
#4 | 2755043-4-PASS.patch | 10.93 KB | damiankloip |
#4 | 2755043-4-tests-only-FAIL.patch | 8.13 KB | damiankloip |
#2 | 2755043.patch | 1.95 KB | damiankloip |
Comments
Comment #2
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedHere is the fix. Tests on their way but want to see if anything is breaking with this. Don't think it should but you just don't know with Drupal.
Comment #4
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedWith a failing test. I had to extend the tests to use the entity_test_mul_changed entity type as that gives us a name long enough that it will get truncated and hashed for field storage.
Comment #6
catchgreater
But that's fixable on commit.
Rest looks fine.
Comment #7
dawehnerThe patch itself looks good, but I'm actively wondering whether we also need to fix
EntityViewsData
as well. I guess though as we use the table mapping automatically we are fine?Comment #8
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedYes. I couldn't find an issue with the stuff mapped from EntityViewsData, just usage with our default field implementation.
Comment #9
dawehnerWFM
Comment #12
catchCommitted/pushed to all three 8.x branches, thank!
Comment #14
jibranI have to fix that for DER as well then.