[BUGFIX] Don't force lowercase on SQL SET() values 63/40463/2
authorStephan Großberndt <stephan@grossberndt.de>
Thu, 11 Jun 2015 09:50:53 +0000 (11:50 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 19 Jun 2015 09:23:25 +0000 (11:23 +0200)
With this patch Database Analyzer no longer complains about SQL SET()
values in upper- or mixed case when checking field types.

Resolves: #67413
Releases: master, 6.2
Change-Id: I5cd1689bce21642b278a94d970ab2d3301c644f0
Reviewed-on: http://review.typo3.org/40463
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
typo3/sysext/install/Classes/Service/SqlSchemaMigrationService.php
typo3/sysext/install/Tests/Unit/Service/SqlSchemaMigrationServiceTest.php

index 392b4be..5a73b37 100644 (file)
@@ -270,15 +270,12 @@ class SqlSchemaMigrationService {
 
                                                                                // 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
+                                                                               // The regex does just trigger for the first word followed by parentheses
                                                                                // 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];'
-                                                                                       ),
+                                                                                       '/^([a-zA-Z0-9]+)(\([^)]*\)\s.*)/',
+                                                                                       function($matches) { return strtolower($matches[1]) . $matches[2]; },
                                                                                        $fieldC
                                                                                );
 
index f06df3c..64e99d2 100644 (file)
@@ -217,6 +217,38 @@ class SqlSchemaMigrationServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
+       public function getDatabaseExtraIgnoresCaseDifferenceButKeepsCaseInSetIntact() {
+               $subject = new SqlSchemaMigrationService();
+               $differenceArray = $subject->getDatabaseExtra(
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'subtype' => 'SET(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
+                                       )
+                               )
+                       ),
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'subtype' => 'set(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
+                                       )
+                               )
+                       )
+               );
+
+               $this->assertEquals(
+                       $differenceArray,
+                       array(
+                               'extra' => array(),
+                               'diff' => array(),
+                               'diff_currentValues' => NULL,
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
        public function getDatabaseExtraDoesNotLowercaseReservedWordsForTheComparison() {
                $subject = new SqlSchemaMigrationService();
                $differenceArray = $subject->getDatabaseExtra(