Skip to content

Commit b68e791

Browse files
authored
Merge pull request #198 from middlebrain/query_date_property_fix
Fix querying date properties
2 parents 7c84093 + fc72469 commit b68e791

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

features/all/phpcr_query.feature

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: Execute a query
1212
Then the command should not fail
1313
And I should see a table containing the following rows:
1414
| a.jcr:createdBy |
15-
| admin |
15+
| admin |
1616

1717
Scenario: Execute query invalid language
1818
Given I execute the "query 'SELECT * FROM [nt:unstructured]' --language=FRENCH" command
@@ -33,3 +33,7 @@ Feature: Execute a query
3333
Scenario: Execute query with no query
3434
Given I execute the "query --language=xpath" command
3535
Then the command should fail
36+
37+
Scenario: Execute query by selecting date property
38+
Given I execute the "query --limit=1 'SELECT [jcr:created] FROM [nt:file]'" command
39+
Then the command should not fail

src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function formatQueryResult(QueryResultInterface $result, OutputInterface
7676
], $row->getValues());
7777

7878
foreach ($values as &$value) {
79+
if ($value instanceof \DateTime) {
80+
$value = $value->format('c');
81+
continue;
82+
}
83+
7984
$value = $this->textHelper->truncate($value, 255);
8085
}
8186

0 commit comments

Comments
 (0)