API page: https://api.drupal.org/api/drupal/includes%21entity.inc/class/EntityFiel...
Enter a descriptive title (above) relating to class EntityFieldQuery, then describe the problem you have found:
I write a module centity, which create a custom entity type called "centity", and its table like :
$schema['centity'] = array(
'description' => 'Centity.',
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique centity ID.',
),
'type' => array(
'description' => 'The {centity_type}.type of this centity.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'type' => array('type'),
),
'primary key' => array('cid'),
);
$schema['centity_type'] = array(
'description' => 'Stores information about all defined {centity} types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique centity type identifier.',
),
'type' => array(
'description' => 'The machine-readable name of this centity type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this centity type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
) + entity_exportable_schema_fields(),
'primary key' => array('id'),
'unique keys' => array(
'type' => array('type'),
),
);
After enable centity, I create a bundle "special_join_record", and add two entityreference fields "field_special" and "field_user".
Then I create a "special_join_record" content.
Now I uninstall centity module, and install it again.
We know that table "centity" and "centity_type" are both empty.
But the two fields table, because I did't delete the content before uninstall centity module, shoud have a record like :
centity | special_join_record | 0 | 1 | 1 | und | 0 | 1225
Now I write a query using EntityFieldQuery:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'centity')
->entityCondition('bundle', 'special_join_record');
$result = $query->execute();The result is empty, it' ok.
But when I write a query :
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'centity')
->entityCondition('bundle', 'special_join_record')
->fieldCondition('field_special', 'target_id', $special->nid->value(), '=')
->fieldCondition('field_user', 'target_id', $user->uid, '=');
$result = $query->execute();
The result has a record.
Table "centity" and "centity_type" are still empty.
I think this shoud be a bug.
Comments
Comment #1
longwaveDuplicate of #2212619: EntityFieldQuery wrong result