Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions Classes/Core/Functional/Framework/DataHandling/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,23 @@ public static function import(string $path): void
$platform = $connection->getDatabasePlatform();
// @todo Check if we can use the cached schema information here instead.
$tableDetails = $connection->createSchemaManager()->introspectTable($tableName);
foreach ($dataSet->getElements($tableName) as $element) {
// 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
$fields = $dataSet->getFields($tableName);
$elements = $dataSet->getElements($tableName);
if ($fields !== null && $elements !== []) {
$types = [];
foreach ($element as $columnName => $columnValue) {
foreach ($fields as $columnName) {
$types[$columnName] = $columnType = $tableDetails->getColumn($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);
if ($columnType instanceof JsonType) {
// JSON values in CSV files are encoded and must be converted before insertion.
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);
}
Testbase::resetTableSequences($connection, $tableName);
}
Expand Down