Issue #3189174 by tstoeckler, daffie: Entity query fails for multi-property base fields if no property is specified
parent
d1064c3fe3
commit
4a3f45abfc
|
@ -250,6 +250,14 @@ class Tables implements TablesInterface {
|
||||||
$key++;
|
$key++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If there are no additional specifiers but the field has a main
|
||||||
|
// property, use that to look up the column name.
|
||||||
|
elseif ($field_storage && $column) {
|
||||||
|
$columns = $field_storage->getColumns();
|
||||||
|
if (isset($columns[$column])) {
|
||||||
|
$sql_column = $table_mapping->getFieldColumnName($field_storage, $column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$table = $this->ensureEntityTable($index_prefix, $sql_column, $type, $langcode, $base_table, $entity_id_field, $entity_tables);
|
$table = $this->ensureEntityTable($index_prefix, $sql_column, $type, $langcode, $base_table, $entity_id_field, $entity_tables);
|
||||||
}
|
}
|
||||||
|
|
|
@ -975,7 +975,7 @@ class EntityQueryTest extends EntityKernelTestBase {
|
||||||
'name' => $this->randomMachineName(),
|
'name' => $this->randomMachineName(),
|
||||||
'vid' => 'tags',
|
'vid' => 'tags',
|
||||||
'description' => [
|
'description' => [
|
||||||
'value' => $this->randomString(),
|
'value' => 'description1',
|
||||||
'format' => 'format1',
|
'format' => 'format1',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
@ -985,20 +985,37 @@ class EntityQueryTest extends EntityKernelTestBase {
|
||||||
'name' => $this->randomMachineName(),
|
'name' => $this->randomMachineName(),
|
||||||
'vid' => 'tags',
|
'vid' => 'tags',
|
||||||
'description' => [
|
'description' => [
|
||||||
'value' => $this->randomString(),
|
'value' => 'description2',
|
||||||
'format' => 'format2',
|
'format' => 'format2',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$term2->save();
|
$term2->save();
|
||||||
|
|
||||||
|
// Test that the properties can be queried directly.
|
||||||
|
$ids = $this->container->get('entity_type.manager')
|
||||||
|
->getStorage('taxonomy_term')
|
||||||
|
->getQuery()
|
||||||
|
->condition('description.value', 'description1')
|
||||||
|
->execute();
|
||||||
|
$this->assertCount(1, $ids);
|
||||||
|
$this->assertEquals($term1->id(), reset($ids));
|
||||||
|
|
||||||
$ids = $this->container->get('entity_type.manager')
|
$ids = $this->container->get('entity_type.manager')
|
||||||
->getStorage('taxonomy_term')
|
->getStorage('taxonomy_term')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->condition('description.format', 'format1')
|
->condition('description.format', 'format1')
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$this->assertCount(1, $ids);
|
$this->assertCount(1, $ids);
|
||||||
$this->assertEqual($term1->id(), reset($ids));
|
$this->assertEquals($term1->id(), reset($ids));
|
||||||
|
|
||||||
|
// Test that the main property is queried if no property is specified.
|
||||||
|
$ids = $this->container->get('entity_type.manager')
|
||||||
|
->getStorage('taxonomy_term')
|
||||||
|
->getQuery()
|
||||||
|
->condition('description', 'description1')
|
||||||
|
->execute();
|
||||||
|
$this->assertCount(1, $ids);
|
||||||
|
$this->assertEquals($term1->id(), reset($ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue