Entity query on entity base field cannot target reference

Created on 13 May 2022, about 2 years ago
Updated 21 March 2023, over 1 year ago

Problem/Motivation

When an entity revision reference field is added to a fieldable entity, entity queries can add conditions on the referenced entity via the property "entity" like ->condition('field_reference.entity', 1). But when the entity revision reference is a base field of an entity (like the billing profile of a commerce order) the "entity" property is not working and queries like ->condition('billing_profile.entity', 1) will return an error Drupal\Core\Entity\Query\QueryException: 'billing_profile' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 375 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

We encountered the error while debugging an search API index πŸ› Entity referenced by an entity revision base field does not update search index Closed: duplicate , it is unclear where the error and the solution resides.

Steps to reproduce

  • Install the commerce_order module
  • Create an order with a billing profile
  • Make a query with a billing profile field condition

Current behaviour: an error is triggered
Expected behaviour: conditions can target billing profile fields.

πŸ› Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland Aerzas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024