Commit 4a3f45ab authored by catch's avatar catch
Browse files

Issue #3189174 by tstoeckler, daffie: Entity query fails for multi-property...

Issue #3189174 by tstoeckler, daffie: Entity query fails for multi-property base fields if no property is specified
parent d1064c3f
......@@ -250,6 +250,14 @@ public function addField($field, $type, $langcode) {
$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);
}
......
......@@ -975,7 +975,7 @@ public function testBaseFieldMultipleColumns() {
'name' => $this->randomMachineName(),
'vid' => 'tags',
'description' => [
'value' => $this->randomString(),
'value' => 'description1',
'format' => 'format1',
],
]);
......@@ -985,20 +985,37 @@ public function testBaseFieldMultipleColumns() {
'name' => $this->randomMachineName(),
'vid' => 'tags',
'description' => [
'value' => $this->randomString(),
'value' => 'description2',
'format' => 'format2',
],
]);
$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')
->getStorage('taxonomy_term')
->getQuery()
->condition('description.format', 'format1')
->execute();
$this->assertCount(1, $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->assertEqual($term1->id(), reset($ids));
$this->assertEquals($term1->id(), reset($ids));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment