mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Use the correct variable as the key into $record
It was using $fieldName, which is the CSV field name, not the database
field name. This prevents duplicate detection from working. It now
properly uses $SQL_fieldName.
Update CsvBulkLoaderTest to remove keys that are nonexistent in the CSV
test data. Having them causes the test to fail with an undefined-index
error. This did not previously fail because of the bug in CsvBulkLoader
that this patch fixes. This partially reverts c4eac53
.
This commit is contained in:
parent
131e21d777
commit
bd5c8520bb
@ -166,7 +166,7 @@ class CsvBulkLoader extends BulkLoader {
|
||||
foreach($this->duplicateChecks as $fieldName => $duplicateCheck) {
|
||||
if(is_string($duplicateCheck)) {
|
||||
$SQL_fieldName = Convert::raw2sql($duplicateCheck);
|
||||
if(!isset($record[$fieldName]) || empty($record[$fieldName])) { //skip current duplicate check if field value is empty
|
||||
if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) { //skip current duplicate check if field value is empty
|
||||
continue;
|
||||
}
|
||||
$SQL_fieldValue = Convert::raw2sql($record[$fieldName]);
|
||||
|
@ -152,9 +152,7 @@ class CsvBulkLoaderTest extends SapphireTest {
|
||||
$filepath = $this->getCurrentAbsolutePath() . '/CsvBulkLoaderTest_PlayersWithId.csv';
|
||||
$loader->duplicateChecks = array(
|
||||
'ExternalIdentifier' => 'ExternalIdentifier',
|
||||
'NonExistantIdentifier' => 'ExternalIdentifier',
|
||||
'ExternalIdentifier' => 'ExternalIdentifier',
|
||||
'AdditionalIdentifier' => 'ExternalIdentifier'
|
||||
);
|
||||
$results = $loader->load($filepath);
|
||||
$createdPlayers = $results->Created();
|
||||
|
Loading…
Reference in New Issue
Block a user