Bug #67413
closedDatabase Analyzer complains about sets with values having uppercase letters
100%
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 );
Updated by Stephan Großberndt over 9 years ago
Since DECIMAL(11, 2)
is valid too, matching on integers only is not possible.
Instead lowercasing should happen only for the part in front of the brackets:
$fieldC = preg_replace_callback( '/^([a-zA-Z0-9]+)(\(.*\)\s.*)/', create_function( '$matches', 'return strtolower($matches[1]) . $matches[2];' ), $fieldC );
Updated by Stephan Großberndt over 9 years ago
- Status changed from New to In Progress
Updated by Gerrit Code Review over 9 years ago
- Status changed from In Progress to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40176
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40176
Updated by Gerrit Code Review over 9 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40463
Updated by Stephan Großberndt over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 67b6c3308e6cdc5c4fa7bd5de71d4548e879d855.