The Sarnia entity implementation only handles entity loads when an entity id is passed. This causes things that use EFQ to query entities to throw an exception. Here's an example of this occurring with drush's entity-read command:

$ drush entity-read sarnia_custom_entity
WD php: EntityFieldQueryException: Entity sarnia_custom_entity has no base table. in EntityFieldQuery->propertyQuery() (line 1200 of                               [error]

\includes\entity.inc).
EntityFieldQueryException: Entity <em class="placeholder">sarnia_custom_entity</em> has no base table. in EntityFieldQuery->propertyQuery() (line 1200 of C:\xampp\htdocs\
hhmi\includes\entity.inc).
Drush command terminated abnormally due to an unrecoverable error.                                                                                                      [error]

While this looks like the same error as #1779762: Issue with sarnia_entity_type not yet available in hook_entity_info, that doesn't fix the problem here, or allow EFQ to function.

I've created a patch that using the hook_entity_query_alter hook to insert a query execute callback to handle queries on sarnia entities. Currently, my callback function is *only* handling the "return all entities" query for a given sarnia entity type. This involved some changes to the entity load() method in the SarniaController class. If anyone wants to build out a handler that handles field queries, be my guest.

One useful side-effect of this change is that you can create a new Search API index that uses Sarnia indexes as a source, and populate that index. The reason this is useful is that you can then use the Search API Multi-Index module to search across regular Search API Solr indexes, plus Sarnia indexes, and get a unified search result of Drupal and non-Drupal content.

CommentFileSizeAuthor
sarnia-entity-query-alter.patch4.34 KBkrisweinhold
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

krisweinhold’s picture

Issue summary: View changes

corrected path

jmdeleon’s picture

Status: Active » Closed (outdated)