diff --git a/Classes/Core/Functional/Framework/DataHandling/DataSet.php b/Classes/Core/Functional/Framework/DataHandling/DataSet.php index ade2f3d1..3390c36c 100644 --- a/Classes/Core/Functional/Framework/DataHandling/DataSet.php +++ b/Classes/Core/Functional/Framework/DataHandling/DataSet.php @@ -77,20 +77,27 @@ public static function import(string $path): void break; } } - foreach ($dataSet->getElements($tableName) as $element) { + $fields = $dataSet->getFields($tableName); + $elements = $dataSet->getElements($tableName); + if ($fields !== null && $elements !== []) { // Some DBMS like postgresql are picky about inserting blob types with correct cast, setting // types correctly (like Connection::PARAM_LOB) allows doctrine to create valid SQL $types = []; - foreach ($element as $columnName => $columnValue) { + foreach ($fields as $columnName) { $types[$columnName] = $columnType = $columnInfos[$columnName]->getType(); - // JSON-Field data is converted (json-encode'd) within $connection->insert(), and since json field - // data can only be provided json encoded in the csv dataset files, we need to decode them here. - if ($columnValue !== null && $columnType instanceof JsonType) { - $element[$columnName] = $columnType->convertToPHPValue($columnValue, $platform); + // JSON-Field data is converted (json-encode'd) within $connection->bulkInsert(), and since json + // field data can only be provided json encoded in the csv dataset files, we need to decode them + // here. + if ($columnType instanceof JsonType) { + foreach ($elements as &$element) { + if ($element[$columnName] !== null) { + $element[$columnName] = $columnType->convertToPHPValue($element[$columnName], $platform); + } + } + unset($element); } } - // Insert the row - $connection->insert($tableName, $element, $types); + $connection->bulkInsert($tableName, $elements, $fields, $types); } if ($autoIncrementColumnName !== null) { Testbase::resetTableSequences($connection, $tableName, $autoIncrementColumnName);