While migrating the EFQ code in #1188388: Entity translation UI in core to EFQ2 I stumbled upon this: I needed to count the number of field values for a certain field, which may be shared among different entities (this is the scenario I was using for testing). The count query always returned the total number of values no matter which entity type the entity query was concerning: if I had 3 values, one for nodes, one for comments and one for taxonomy the count query returned 3 for all the entity types instead of one.
Comment | File | Size | Author |
---|---|---|---|
#15 | 1828790_15.patch | 3.48 KB | chx |
#14 | 1828790_14.patch | 3.56 KB | chx |
#14 | 1828790_14_test_only.patch | 1.57 KB | chx |
#13 | 1828790-test_entity_count_query_wip.do_not_test.patch | 1.6 KB | pfrenssen |
#7 | eq-count_shared_fields-1828790-7.patch | 1.99 KB | plach |
Comments
Comment #1
plachIt seems we are missing an entity type condition in the SQL query.
Comment #2
plachBetter title
Comment #3
chx CreditAttribution: chx commentedGreat find.
Comment #4
Fabianx CreditAttribution: Fabianx commented#1: eq-count_shared_fields-1828790-1.patch queued for re-testing.
Comment #6
chx CreditAttribution: chx commentedYou need to add to the join condition otherwise LEFT JOINs break.
Comment #7
plachThis should be ok, still needs tests though.
Comment #8
plachComment #9
chx CreditAttribution: chx commentedpfrenssen is working on a test (and I am helping).
Comment #10
plachFWIW #9 actually fixed the OP case.
Comment #12
Fabianx CreditAttribution: Fabianx commented#7: eq-count_shared_fields-1828790-7.patch queued for re-testing.
Comment #13
pfrenssenHere's what I have so far. This still needs work but the office I'm working at is closing. I'm continuing tomorrow.
Comment #14
chx CreditAttribution: chx commentedAs I did little more than adding an assert and comments #13 and added #7 I don't feel I am RTBC'ing my own.
Comment #15
chx CreditAttribution: chx commentedEven better comments after talking to plach.
Comment #16
webchickCommitted and pushed to 8.x. Thanks!
Comment #17
YesCT CreditAttribution: YesCT commented#15: 1828790_15.patch queued for re-testing.
Comment #19
pfrenssenThis has already been committed, it is not necessary to test the patch any more.