Skip to content

Commit 0cd5e3f

Browse files
committed
Fix PK Chunk return formatting
1 parent 37f7ee8 commit 0cd5e3f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/Bulk.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,12 @@ public function batchResult($jobId, $batchId, $isBatchedResult = false, $resultI
317317
//if this is a query result, the main result page will have an array of result ids to follow for hte query results
318318
if ($resultId) {
319319
$url = $url.'/'.$resultId;
320+
//results returned in contentType supplied by the creation of the job
320321
$resultPostArray['format'] = $format;
322+
//all results that have a $resultId should be returned without lowercase formatting
323+
$resultPostArray['lowerCaseHeaders'] = false;
321324
}else{
325+
//result object returned in xml if selecting csv as contentType
322326
$resultPostArray['format'] = $this->batchResponseFormatFromContentType($format);
323327
}
324328

src/Salesforce.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,13 @@ public function call_api($method, $url, $options = [], $debug_info = [])
472472
unset($options['format']);
473473
}
474474

475+
//required so csv return matches json return when creating new records
476+
$lowerCaseHeaders = true;
477+
if (isset($options['lowerCaseHeaders'])) {
478+
$lowerCaseHeaders = $options['lowerCaseHeaders'];
479+
unset($options['lowerCaseHeaders']);
480+
}
481+
475482
$response = $this->oauth2Client->{$method}($url, $options);
476483

477484
/* @var $response \GuzzleHttp\Psr7\Response */
@@ -494,7 +501,7 @@ public function call_api($method, $url, $options = [], $debug_info = [])
494501
$json = json_encode($xml);
495502
$response_array = json_decode($json, true);
496503
} elseif ($format == 'csv') {
497-
$response_array = csvToArray((string) $response->getBody(), $lowerCaseHeaders = true);
504+
$response_array = csvToArray((string) $response->getBody(), $lowerCaseHeaders);
498505
} else {
499506
$response_array = json_decode((string) $response->getBody(), true);
500507
}

tests/BulkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function testRunPkChunkQueryBatch()
249249
}
250250
$this->assertEquals($batchId, $batch->id);
251251
foreach ($batch->records as $record) {
252-
$this->assertEquals($firstAccountId, $record['id']);
252+
$this->assertEquals($firstAccountId, $record['Id']);
253253
break;
254254
}
255255
}

0 commit comments

Comments
 (0)