#67413Database Analyzer complains about sets with values having uppercase letters
Description
Definition in ext_tables.sql:
subtype set('Tx_MyExt_Domain_Model_Xyz','Tx_MyExt_Domain_Model_Abc','') NOT NULL DEFAULT '',
In TYPO3 4.7 this worked without problems (MySQL has no problems with upper- or mixed case in set), in TYPO3 6.2 the database compare complains and wants to change the case of all set entries to lowercase:
subtype set('tx_myext_domain_model_xyz','tx_myext_domain_model_abc','') NOT NULL DEFAULT '',
Luckily I spotted this before applying all database changes, otherwise the subtypes had been ‘’ in all records now..
The problem is in typo3\sysext\install\Classes\Service\SqlSchemaMigrationService.php : SqlSchemaMigrationService->getDatabaseExtra()
// Lowercase the field type to surround false-positive schema changes to be
// reported just because of different caseing of characters
// The regex does just trigger for the first word followed by round brackets
// that contain a length. It does not trigger for e.g. "PRIMARY KEY" because
// "PRIMARY KEY" is being returned from the DB in upper case.
$fieldC = preg_replace_callback(
'/^([a-zA-Z0-9]+\(.*\))(\s)(.*)/',
create_function(
'$matches',
'return strtolower($matches[1]) . $matches[2] . $matches[3];'
),
$fieldC
);
This should lead to lowercasing for fieldtypes with a length e.g. int (11) but matches for set or enum too currently.
By changing the regexp to match only fields with a number in brackets this is solved:
// Lowercase the field type to surround false-positive schema changes to be
// reported just because of different caseing of characters
// The regex does just trigger for the first word followed by round brackets
// that contain a length. It does not trigger for e.g. "PRIMARY KEY" because
// "PRIMARY KEY" is being returned from the DB in upper case.
$fieldC = preg_replace_callback(
'/^([a-zA-Z0-9]+\(\d*\))(\s)(.*)/',
create_function(
'$matches',
'return strtolower($matches[1]) . $matches[2] . $matches[3];'
),
$fieldC
);