[BUGFIX] Add support for multi-line INSERT statements in static data 54/51854/5
authorThomas Hohn <thomas@hohn.dk>
Sat, 25 Feb 2017 14:03:05 +0000 (15:03 +0100)
committerHelmut Hummel <typo3@helhum.io>
Sun, 26 Feb 2017 08:52:03 +0000 (09:52 +0100)
Join consecutive lines for INSERT statements in ext_tables_static+adt.sql
using a space instead of a linefeed to avoid parser errors.

Resolves: #78892
Releases: master
Change-Id: Ide550419b7ef41109a660a671b8aba65a33eb6b3
Reviewed-on: https://review.typo3.org/51854
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
typo3/sysext/core/Classes/Database/Schema/SqlReader.php
typo3/sysext/core/Tests/Unit/Database/Schema/SqlReaderTest.php

index 095b45c..5df5f89 100644 (file)
@@ -102,7 +102,7 @@ class SqlReader
                 }
                 $statementArrayPointer++;
             } else {
-                $statementArray[$statementArrayPointer] .= LF;
+                $statementArray[$statementArrayPointer] .= ' ';
             }
         }
 
index daedec8..1547714 100644 (file)
@@ -86,6 +86,23 @@ class SqlReaderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
+    public function getInsertStatementArrayResultWithNewline()
+    {
+        $result = $this->subject->getInsertStatementArray(
+            'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
+            LF .
+            'INSERT INTO aTestTable(`aTestField`) ' .
+            LF .
+            'VALUES(1);'
+        );
+
+        $this->assertCount(1, $result);
+        $this->assertSame('INSERT INTO aTestTable(`aTestField`) VALUES(1);', array_pop($result));
+    }
+
+    /**
+     * @test
+     */
     public function getCreateTableStatementArrayResult()
     {
         $result = $this->subject->getCreateTableStatementArray(