Unverified Commit 44b9b25c authored by alexpott's avatar alexpott

Issue #2956411 by amateescu: Simplify \Drupal\Core\Entity\Query\Sql\Tables::addField() a little

parent 9ac4d544
......@@ -94,9 +94,11 @@ public function addField($field, $type, $langcode) {
$specifier = $specifiers[$key];
if (isset($field_storage_definitions[$specifier])) {
$field_storage = $field_storage_definitions[$specifier];
$column = $field_storage->getMainPropertyName();
}
else {
$field_storage = FALSE;
$column = NULL;
}
// If there is revision support, only the current revisions are being
......@@ -121,8 +123,6 @@ public function addField($field, $type, $langcode) {
// Check whether this field is stored in a dedicated table.
if ($field_storage && $table_mapping->requiresDedicatedTableStorage($field_storage)) {
$delta = NULL;
// Find the field column.
$column = $field_storage->getMainPropertyName();
if ($key < $count) {
$next = $specifiers[$key + 1];
......@@ -176,10 +176,6 @@ public function addField($field, $type, $langcode) {
}
$table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta);
$sql_column = $table_mapping->getFieldColumnName($field_storage, $column);
$property_definitions = $field_storage->getPropertyDefinitions();
if (isset($property_definitions[$column])) {
$this->caseSensitiveFields[$field] = $property_definitions[$column]->getSetting('case_sensitive');
}
}
// The field is stored in a shared table.
else {
......@@ -239,18 +235,17 @@ public function addField($field, $type, $langcode) {
}
$table = $this->ensureEntityTable($index_prefix, $sql_column, $type, $langcode, $base_table, $entity_id_field, $entity_tables);
}
// If there is a field storage (some specifiers are not), check for case
// sensitivity.
if ($field_storage) {
$column = $field_storage->getMainPropertyName();
$base_field_property_definitions = $field_storage->getPropertyDefinitions();
if (isset($base_field_property_definitions[$column])) {
$this->caseSensitiveFields[$field] = $base_field_property_definitions[$column]->getSetting('case_sensitive');
}
// If there is a field storage (some specifiers are not) and a field
// column, check for case sensitivity.
if ($field_storage && $column) {
$property_definitions = $field_storage->getPropertyDefinitions();
if (isset($property_definitions[$column])) {
$this->caseSensitiveFields[$field] = $property_definitions[$column]->getSetting('case_sensitive');
}
}
// If there are more specifiers to come, it's a relationship.
if ($field_storage && $key < $count) {
// Computed fields have prepared their property definition already, do
......
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