[FEATURE] dbal: Ignore MySQL ENGINE in database schema compare 55/40055/3
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 6 Jun 2015 18:04:26 +0000 (20:04 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 18 Jun 2015 07:29:50 +0000 (09:29 +0200)
Ignore the database engine when comparing the expected and the
current schema information if DBAL is enabled. The MySQL specific
storage engines are not available on other DBMS.

Resolves: #67302
Releases: master
Change-Id: Ic57233de7c4294454609955e802498053f186326
Reviewed-on: http://review.typo3.org/40055
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/install/Classes/Service/SqlSchemaMigrationService.php
typo3/sysext/install/Tests/Unit/Service/SqlSchemaMigrationServiceTest.php

index 05adcbd..dee231b 100644 (file)
@@ -261,6 +261,9 @@ class SqlSchemaMigrationService {
                                                        if (is_array($info[$theKey])) {
                                                                foreach ($info[$theKey] as $fieldN => $fieldC) {
                                                                        $fieldN = str_replace('`', '', $fieldN);
+                                                                       if ($this->isDbalEnabled() && $fieldN === 'ENGINE') {
+                                                                               continue;
+                                                                       }
                                                                        if ($fieldN == 'COLLATE') {
                                                                                // @todo collation support is currently disabled (needs more testing)
                                                                                continue;
@@ -638,4 +641,13 @@ class SqlSchemaMigrationService {
                return $whichTables;
        }
 
+       /**
+        * Checks if DBAL is enabled for the database connection
+        *
+        * @return bool
+        */
+       protected function isDbalEnabled() {
+               return \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal');
+       }
+
 }
index 179a501..26918ce 100644 (file)
@@ -329,4 +329,80 @@ class SqlSchemaMigrationServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
        }
 
+       /**
+        * @test
+        */
+       public function getDatabaseExtraIncludesEngineIfMySQLIsUsed() {
+               $subject = $this->getAccessibleMock(SqlSchemaMigrationService::class, array('isDbalEnabled'), array(), '', FALSE);
+               $subject->expects($this->any())->method('isDbalEnabled')->will($this->returnValue(FALSE));
+               $differenceArray = $subject->getDatabaseExtra(
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'foo' => 'INT(11) DEFAULT \'0\' NOT NULL',
+                                       ),
+                                       'extra' => array(
+                                               'ENGINE' => 'InnoDB'
+                                       )
+                               )
+                       ),
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'foo' => 'int(11) DEFAULT \'0\' NOT NULL',
+                                       ),
+                                       'extra' => array(
+                                               'ENGINE' => 'InnoDB'
+                                       )
+                               )
+                       )
+               );
+
+               $this->assertSame(
+                       $differenceArray,
+                       array(
+                               'extra' => array(),
+                               'diff' => array(),
+                               'diff_currentValues' => NULL,
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function getDatabaseExtraExcludesEngineIfDbalIsUsed() {
+               $subject = $this->getAccessibleMock(SqlSchemaMigrationService::class, array('isDbalEnabled'), array(), '', FALSE);
+               $subject->expects($this->any())->method('isDbalEnabled')->will($this->returnValue(TRUE));
+               $differenceArray = $subject->getDatabaseExtra(
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'foo' => 'INT(11) DEFAULT \'0\' NOT NULL',
+                                       ),
+                                       'extra' => array(
+                                               'ENGINE' => 'InnoDB'
+                                       )
+                               )
+                       ),
+                       array(
+                               'tx_foo' => array(
+                                       'fields' => array(
+                                               'foo' => 'int(11) DEFAULT \'0\' NOT NULL',
+                                       ),
+                                       'extra' => array()
+                               )
+                       )
+               );
+
+               $this->assertSame(
+                       $differenceArray,
+                       array(
+                               'extra' => array(),
+                               'diff' => array(),
+                               'diff_currentValues' => NULL,
+                       )
+               );
+       }
+
 }