Skip to content

Commit

Permalink
so close
Browse files Browse the repository at this point in the history
  • Loading branch information
janette committed Mar 15, 2024
1 parent eff0499 commit e67bed3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 13 additions & 4 deletions modules/datastore/src/Controller/QueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,19 @@ public function formatResponse(
*/
private function fixHeaderRow(RootedJsonData &$result) {
try {
$schema = $result->{'$.schema'};
// Query has are no explicit properties; we should assume one table.
$header_row = array_column(reset($schema)['fields'], 'description');

// if (!empty($result->{'$.query.properties'})) {
// $header_row = $result->{'$.query.properties'};
// array_walk($header_row, function (&$header) {
// if (is_array($header)) {
// $header = $header['alias'] ?? $header['property'];
// }
// });
// }
// else {
$schema = $result->{'$.schema'};
// Query has are no explicit properties; we should assume one table.
$header_row = array_column(reset($schema)['fields'], 'description');
// }
if (empty($header_row) || !is_array($header_row)) {
throw new \DomainException("Could not generate header for CSV.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,16 @@ private function getQueryResult($data, $id = NULL, $index = NULL, $info = []) {
*/
public function testResourceQueryCsv() {
$data = json_encode([
"properties" => [
[
"resource" => "t",
"property" => "state",
],
],
"results" => TRUE,
"format" => "csv",
]);
$result = $this->getQueryResult($data);

$this->assertTrue($result instanceof CsvResponse);
$this->assertEquals(200, $result->getStatusCode());
}
Expand Down

0 comments on commit e67bed3

Please sign in to comment.