- 🇦🇺Australia acbramley
Doh, just reported a dupe of this 🐛 Multiple conditions on the same subfield in an entity query fails to join properly Closed: duplicate
- 🇦🇺Australia acbramley
As per comments in 🐛 Multiple conditions on the same subfield in an entity query fails to join properly Closed: duplicate the issue is with not rejoining on the field table for the 2nd relationship, using the workaround in #3 we can see the correct joins are used and tables in conditions are correctly varied.
SELECT "base_table"."revision_id" AS "revision_id", "base_table"."id" AS "id" FROM "proj_personalisation_criteria" "base_table" LEFT JOIN "proj_pers_criteria__store" "proj_pers_criteria__store" ON "proj_pers_criteria__store"."entity_id" = "base_table"."id" LEFT OUTER JOIN "node" "node" ON "node"."nid" = "proj_pers_criteria__store"."store_target_id" LEFT JOIN "node__s_code" "node__s_code" ON "node__s_code"."entity_id" = "node"."nid" LEFT JOIN "proj_pers_criteria__stores" "proj_pers_criteria__stores" ON "proj_pers_criteria__stores"."entity_id" = "base_table"."id" LEFT OUTER JOIN "node" "node_2" ON "node_2"."nid" = "proj_pers_criteria__stores"."stores_target_id" LEFT JOIN "node__s_code" "node__s_code_2" ON "node__s_code_2"."entity_id" = "node_2"."nid" WHERE ("node__s_code"."s_code_value" LIKE '%046%' ESCAPE '\\') or ("node__s_code_2"."s_code_value" LIKE '%046%' ESCAPE '\\') GROUP BY "base_table"."revision_id", "base_table"."id" ORDER BY "base_table"."id" ASC LIMIT 50 OFFSET 0
- Status changed to Needs review
about 1 year ago 9:54am 11 October 2023 - 🇮🇳India viren18febS
#3 🐛 Entity query using OR group with the same field name on different relationships doesn't work Active is working for apply the correct joins & conditions for me.
- Status changed to Active
about 1 year ago 11:08am 11 October 2023 - 🇬🇧United Kingdom joachim
Interesting bug!
> the issue is with not rejoining on the field table for the 2nd relationship, using the workaround
I wonder whether it's that the relationship data is being formed in such a way that the 2nd relationship clobbers the first one.
LEFT JOIN taxonomy_term__field_boolean taxonomy_term__field_boolean ON taxonomy_term__field_boolean.entity_id = taxonomy_term_data.tid
The table alias taxonomy_term__field_boolean looks wrong -- it's not containing information on how the taxonomy_term was joined to the base.
- 🇦🇺Australia acbramley
@joachim I'm not sure the relationships are overwriting each other, I think it just sees the 2nd field of the same name and skips it (and yeah for some reason the AND groups fix that).
See the first query I posted in 🐛 Multiple conditions on the same subfield in an entity query fails to join properly Closed: duplicate where there is no second join at all on the field table.