Skip to content
Snippets Groups Projects
Commit 60a17522 authored by catch's avatar catch
Browse files

Issue #2742103 by ekes, dawehner, amateescu:...

Issue #2742103 by ekes, dawehner, amateescu: SqlContentEntityStorageSchema::getDedicatedTableSchema() ignores 'unique keys' from the schema definition
parent c2217cd6
No related branches found
No related tags found
No related merge requests found
......@@ -1837,6 +1837,24 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor
}
}
// Add unique keys.
foreach ($schema['unique keys'] as $index_name => $columns) {
$real_name = $this->getFieldIndexName($storage_definition, $index_name);
foreach ($columns as $column_name) {
// Unique keys can be specified as either a column name or an array with
// column name and length. Allow for either case.
if (is_array($column_name)) {
$data_schema['unique keys'][$real_name][] = array(
$table_mapping->getFieldColumnName($storage_definition, $column_name[0]),
$column_name[1],
);
}
else {
$data_schema['unique keys'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name);
}
}
}
// Add foreign keys.
foreach ($schema['foreign keys'] as $specifier => $specification) {
$real_name = $this->getFieldIndexName($storage_definition, $specifier);
......
......@@ -820,6 +820,16 @@ public function testDedicatedTableSchema() {
'length' => 32,
'not null' => FALSE,
),
'area' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'depth' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'foreign keys' => array(
'color' => array(
......@@ -829,8 +839,14 @@ public function testDedicatedTableSchema() {
),
),
),
'unique keys' => array(),
'indexes' => array(),
'unique keys' => array(
'area' => array('area'),
'shape' => array(array('shape', 10)),
),
'indexes' => array(
'depth' => array('depth'),
'color' => array(array('color', 3)),
),
));
$field_storage = $this->storageDefinitions[$field_name];
......@@ -905,11 +921,27 @@ public function testDedicatedTableSchema() {
'length' => 32,
'not null' => FALSE,
),
$field_name . '_area' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
$field_name . '_depth' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
'indexes' => array(
'bundle' => array('bundle'),
'revision_id' => array('revision_id'),
$field_name . '_depth' => array($field_name . '_depth'),
$field_name . '_color' => array(array($field_name . '_color', 3)),
),
'unique keys' => array(
$field_name . '_area' => array($field_name . '_area'),
$field_name . '_shape' => array(array($field_name . '_shape', 10)),
),
'foreign keys' => array(
$field_name . '_color' => array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment