Issue #2742103 by ekes, dawehner, amateescu: SqlContentEntityStorageSchema::getDedicatedTableSchema() ignores 'unique keys' from the schema definition
parent
c2217cd6b7
commit
60a17522f4
|
@ -1837,6 +1837,24 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
|
|||
}
|
||||
}
|
||||
|
||||
// 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 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
|
|||
'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 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
|
|||
),
|
||||
),
|
||||
),
|
||||
'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 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
|
|||
'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(
|
||||
|
|
Loading…
Reference in New Issue