Problem/Motivation
As documented the schema can include: fields, indexes, unique keys and foreign keys. Except for unique keys these are all processed. It seems this got lost somewhere in #2337927: SqlContentEntityStorage::onFieldStorageDefinition(Create|Update|Delete)() is broken for base fields, the code to remove the keys on deletion is still there.
Proposed resolution
Add (back) unique key support.
Remaining tasks
Test (that comes first and will be attached - and failing to start with).
Add the code required as for 'indexes' and 'foreign keys'.
API changes
None - it will work as documented.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 2742103-11.interdiff.txt | 821 bytes | ekes |
| #11 | 2742103-11.getDedicatedTableSchema-unique_keys.patch | 3.7 KB | ekes |
Comments
Comment #2
ekes commentedThink this is the correct test. Adds unique keys along with the indexes.
Comment #3
ekes commentedCorrect test.
It also didn't test additional index in the schema, so adding that as well.
Comment #4
ekes commentedWith fix.
Comment #5
dawehnerJust a note for myself: this method is used for the foreign keys as well
It seems to be that adding a testcase for this case would be helpful as well.
Comment #6
ekes commentedIt's adding index and unique key tests, and foreign key is already tested. What should be added further?
Comment #7
dawehnerWell a unique key without an array for the column names.
Comment #8
ekes commentedAh. So it was testing that line:
$data_schema['unique keys'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name);. What wasn't tested there was the array case in the other half of the if/else where it is a column name and a size. So for completeness added that for index and unique.Comment #9
dawehnerCool, thank you!
Comment #10
amateescu commentedThe patch looks great to me, I just found a small nit:
Should we replace 'Indexes' with 'Unique keys' at the beginning of the sentence?
Comment #11
ekes commentedAh yes. Corrected.
Comment #12
amateescu commentedNice, looks great now :)
Comment #15
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!