In my setup I'm using both field_sql_storage and mongodb_field_storage fields. I ran again into the 'No entity_type' exception thrown by mongodb field storage module, so I had to do some digging.

So in my case the problem is that if I have an entity like for example commerce_coupon, it's fields are not found with EntityFieldQuery. Mongodb grabs the query in mongodb_entity_query_alter and field sql query is not executed. I don't understand how I didn't run into this earlier.

My question is, does this make sense:

 * Implements hook_entity_query_alter().
function mongodb_field_storage_entity_query_alter($query) {
  if(!empty($query->fieldConditions[0]['field']['storage']['type']) && $query->fieldConditions[0]['field']['storage']['type'] == 'mongodb_field_storage')
     $query->executeCallback = 'mongodb_field_storage_query';

in mongodb_field_storage.module

Works for me, but could there be some side effects?

EDIT: The version I'm using is actually not the latest dev version so I haven't tested how http://drupal.org/node/839264 effected

#2 1612374.patch693 byteschx
None View
Members fund testing for the Drupal project. Drupal Association Learn more


lurkingbeast’s picture

Actually I have noticed it before, deleted fields and instances in mysql field_config and field_config_tables never actually got deleted before. Now they do, hooray! :)

chx’s picture

Status: Active » Needs review
693 bytes
None View

Please test on both mongo and sql fields.

mgifford’s picture

Is this related in any way to:

chx’s picture


michaellander’s picture

Chx, we had the same exact issue, and found the same solution as your patch. The patch appears to be working for us.


mgifford’s picture

Can this patch be brought into the next release?

chx’s picture

So far there was only one "yes" so I am a bit hesitant.

chx’s picture

Issue summary: View changes


Island Usurper’s picture

I'll give a +1 to this patch. It's necessary if you're trying to switch to MongoDB, but some module is using EntityFieldQuery on an entity type that doesn't have fields. mongodb_migrate doesn't do anything for those. Of course, that use of EFQ might be a bug—or at least silly—but there's nothing else saying they can't do it, either.