Skip to content

Commit edc4384

Browse files
committed
[TASK] Avoid value decoding in DataSet::import()
TYPO3 v14 no longer converts values to database values when using `Connection::insert()`, which makes decoding values from CSV DataSet files an error. One solution would be to pass the argument to enforce converting values again, which is used here. This is possible since an early introduction of the method argument with [1] and becomes mandantory with [2] flipping the default value. [1] https://review.typo3.org/c/Packages/TYPO3.CMS/+/89293 [2] https://review.typo3.org/c/Packages/TYPO3.CMS/+/90957 Releases: main
1 parent c0c7bf9 commit edc4384

File tree

1 file changed

+10
-2
lines changed
  • Classes/Core/Functional/Framework/DataHandling

1 file changed

+10
-2
lines changed

Classes/Core/Functional/Framework/DataHandling/DataSet.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
namespace TYPO3\TestingFramework\Core\Functional\Framework\DataHandling;
1919

2020
use Doctrine\DBAL\Types\JsonType;
21+
use TYPO3\CMS\Core\Database\Connection;
2122
use TYPO3\CMS\Core\Database\ConnectionPool;
23+
use TYPO3\CMS\Core\Information\Typo3Version;
2224
use TYPO3\CMS\Core\Utility\GeneralUtility;
2325
use TYPO3\TestingFramework\Core\Testbase;
2426

@@ -65,6 +67,7 @@ private function __construct(
6567
*/
6668
public static function import(string $path): void
6769
{
70+
$methodReflection = new \ReflectionMethod(Connection::class, 'insert');
6871
$dataSet = self::read($path, true, true);
6972
foreach ($dataSet->getTableNames() as $tableName) {
7073
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName);
@@ -85,14 +88,19 @@ public static function import(string $path): void
8588
$types[] = $columnType->getBindingType();
8689
}
8790
// Insert the row
88-
$connection->insert($tableName, $element, $types);
91+
// @todo Remove condition when TYPO3 v13 support is dropped.
92+
if (count($methodReflection->getParameters()) === 3) {
93+
$connection->insert($tableName, $element, $types);
94+
continue;
95+
}
96+
$connection->insert($tableName, $element, $types, true);
8997
}
9098
Testbase::resetTableSequences($connection, $tableName);
9199
}
92100
}
93101

94102
/**
95-
* Main entry method: Get at absosulete (!) path to a .csv file, read it and return an instance of self
103+
* Main entry method: Get at absolute (!) path to a .csv file, read it and return an instance of self
96104
*/
97105
public static function read(string $fileName, bool $applyDefaultValues = false, bool $checkForDuplicates = false): self
98106
{

0 commit comments

Comments
 (0)