From fc72469d140eecea6cbf26bbfbdd4285988d9cc5 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 3 Sep 2018 13:19:07 +0200 Subject: [PATCH] Fix querying date properties --- features/all/phpcr_query.feature | 6 +++++- src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/features/all/phpcr_query.feature b/features/all/phpcr_query.feature index 215d18ef..8469f3cf 100644 --- a/features/all/phpcr_query.feature +++ b/features/all/phpcr_query.feature @@ -12,7 +12,7 @@ Feature: Execute a query Then the command should not fail And I should see a table containing the following rows: | a.jcr:createdBy | - | admin | + | admin | Scenario: Execute query invalid language Given I execute the "query 'SELECT * FROM [nt:unstructured]' --language=FRENCH" command @@ -33,3 +33,7 @@ Feature: Execute a query Scenario: Execute query with no query Given I execute the "query --language=xpath" command Then the command should fail + + Scenario: Execute query by selecting date property + Given I execute the "query --limit=1 'SELECT [jcr:created] FROM [nt:file]'" command + Then the command should not fail diff --git a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php index 07400316..a2b9092b 100644 --- a/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php +++ b/src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php @@ -76,6 +76,11 @@ public function formatQueryResult(QueryResultInterface $result, OutputInterface ], $row->getValues()); foreach ($values as &$value) { + if ($value instanceof \DateTime) { + $value = $value->format('c'); + continue; + } + $value = $this->textHelper->truncate($value, 255); }