EntityFieldQuery not returning Bundle data I've defined an entity in hook_entity_info as follows:

function foo_entity_info() {
  return array(
    'Foo' =&gt; array(
      'label' =&gt; t('foo'), 
      'base table' =&gt; 'foo',                                       
      'entity keys' =&gt; array(          
        'id' =&gt; 'bar',          
        'label' =&gt; 'bar',
      ),
      'module' =&gt; 'foo',          
      'fieldable' =&gt; TRUE,
      'bundles' =&gt; array(
        'Foo' =&gt; array(
          'label' =&gt; t('Foo'),
          'admin' =&gt; array(
              'path' =&gt; 'admin/config/foo/fields',
              'access arguments' =&gt; array('access content'),
          ),   
        ),
      ),
      'views controller class' =&gt; 'EntityDefaultViewsController',
    ),
  );
}


When I run the following code:

$info = entity_get_info('Foo'); it all looks OK

When I run the following code:

  $query = new EntityFieldQuery();
  $query-&gt;entityCondition('entity_type','Foo');
  $result = $query-&gt;execute();


it all looks OK

But when I run the following code:

  $query = new EntityFieldQuery();
  $query-&gt;entityCondition('entity_type','Foo')
    -&gt;entityCondition('bundle','Foo');
  $result = $query-&gt;execute();


I get an empty array in $result. This seems wrong.

What should I expect to see in $result and why aren't I seeing it?

Many thanks,

MB
What should I expect to see in $result


You should expect to see an array of data that represents the entities that match your query. This array will contain a key for each entity type it returns, and an array within each of those keyed by the individual entity IDs. The inner-most array will contain bundle key data for the entity. You will need to run the ID(s) through entity_load() or equivalent if you want access to general field/property data for the entities.


  why aren't I seeing it?


Not really possible to say without more information. If you know that you have existing entities that match the criteria, and they're not showing up in an EFQ, that's potentially the sign of a deeper problem with your installation (or it might not be, it depends).

If that's the case, clear your caches and try again. If that doesn't fix it, reinstall your entity module. After that, you're left with step-debugging to find out what DB query is being produced, you can run that against MySQL proper to see what's going on, and so on.