Problem/Motivation
If you omit the base_table from an entity type annotation, then storage operations such as load and save still work.
But queries crash.
This is because DefaultTableMapping assumes the base table if the entity type doesn't define it:
$this->baseTable = $this->prefix . $entity_type->getBaseTable() ?: $entity_type->id();
but Sql\Query doesn't:
if (!$base_table = $this->entityType->getBaseTable()) {
throw new QueryException("No base table for " . $this->entityTypeId . ", invalid query.");
}
Steps to reproduce
Remove the base_table from an entity type.
Clear caches.
Load and save still work, but something requiring a query does not.
Proposed resolution
Add the same fallbacks to Query, or centralize them.
Comments
Comment #2
hchonovI think that all the table name fallbacks should be centralized and be placed inside the corresponding methods of the
ContentEntityTypeclass.Comment #6
larowlanComment #10
mile23I discovered this while trying to develop my own content entity type in Drupal 10.2.
I am unable to uninstall the module because it says things like this:
+1 on #2 to make table discovery consistent.