diff --git a/src/PHPCR/Util/Console/Command/QueryCommand.php b/src/PHPCR/Util/Console/Command/QueryCommand.php
index 956570b..0b2ac79 100644
--- a/src/PHPCR/Util/Console/Command/QueryCommand.php
+++ b/src/PHPCR/Util/Console/Command/QueryCommand.php
@@ -58,7 +58,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$query->setOffset($offset);
}
+ $output->writeln(sprintf('Executing, language: %s', $query->getLanguage()));
+
+ $start = microtime(true);
$result = $query->execute();
+ $elapsed = microtime(true) - $start;
+
$output->writeln("Results:\n");
foreach ($result as $i => $row) {
$output->writeln("\n".($i+1).'. Row (Path: '. $row->getPath() .', Score: '. $row->getScore() .'):');
@@ -66,6 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln("$column: $value");
}
}
+ $output->writeln(sprintf('%.2f seconds', $elapsed));
return 0;
}
diff --git a/src/PHPCR/Util/QOM/QueryBuilder.php b/src/PHPCR/Util/QOM/QueryBuilder.php
index 0f5e27c..25b5c3e 100644
--- a/src/PHPCR/Util/QOM/QueryBuilder.php
+++ b/src/PHPCR/Util/QOM/QueryBuilder.php
@@ -412,7 +412,7 @@ public function getSource()
*
* @return QueryBuilder This QueryBuilder instance.
*
- * @trows RuntimeException if there is not an existing source.
+ * @throws RuntimeException if there is not an existing source.
*/
public function join(SourceInterface $rightSource, JoinConditionInterface $joinCondition)
{
@@ -427,7 +427,7 @@ public function join(SourceInterface $rightSource, JoinConditionInterface $joinC
*
* @return QueryBuilder This QueryBuilder instance.
*
- * @trows RuntimeException if there is not an existing source.
+ * @throws RuntimeException if there is not an existing source.
*/
public function innerJoin(SourceInterface $rightSource, JoinConditionInterface $joinCondition)
{
@@ -442,7 +442,7 @@ public function innerJoin(SourceInterface $rightSource, JoinConditionInterface $
*
* @return QueryBuilder This QueryBuilder instance.
*
- * @trows RuntimeException if there is not an existing source.
+ * @throws RuntimeException if there is not an existing source.
*/
public function leftJoin(SourceInterface $rightSource, JoinConditionInterface $joinCondition)
{
@@ -457,7 +457,7 @@ public function leftJoin(SourceInterface $rightSource, JoinConditionInterface $j
*
* @return QueryBuilder This QueryBuilder instance.
*
- * @trows RuntimeException if there is not an existing source.
+ * @throws RuntimeException if there is not an existing source.
*/
public function rightJoin(SourceInterface $rightSource, JoinConditionInterface $joinCondition)
{
@@ -473,7 +473,7 @@ public function rightJoin(SourceInterface $rightSource, JoinConditionInterface $
*
* @return QueryBuilder This QueryBuilder instance.
*
- * @trows RuntimeException if there is not an existing source.
+ * @throws RuntimeException if there is not an existing source.
*/
public function joinWithType(SourceInterface $rightSource, $joinType, JoinConditionInterface $joinCondition)
{
diff --git a/src/PHPCR/Util/QOM/Sql1Generator.php b/src/PHPCR/Util/QOM/Sql1Generator.php
index 93adf95..bda1beb 100644
--- a/src/PHPCR/Util/QOM/Sql1Generator.php
+++ b/src/PHPCR/Util/QOM/Sql1Generator.php
@@ -26,9 +26,13 @@ public function evalSelector($nodeTypeName, $selectorName = null)
protected function getPathForDescendantQuery($path)
{
- $path = trim($path,"\"'/");
- $sql1 = "/" . str_replace("/","[%]/",$path) ;
- $sql1 .= "[%]/%";
+ if ($path == '/') {
+ $sql1 = '/%';
+ } else {
+ $path = trim($path,"\"'/");
+ $sql1 = "/" . str_replace("/","[%]/",$path) ;
+ $sql1 .= "[%]/%";
+ }
return $sql1;
}
diff --git a/tests/PHPCR/Tests/Util/QOM/Sql1GeneratorTest.php b/tests/PHPCR/Tests/Util/QOM/Sql1GeneratorTest.php
index d2c6b4d..b024bfc 100644
--- a/tests/PHPCR/Tests/Util/QOM/Sql1GeneratorTest.php
+++ b/tests/PHPCR/Tests/Util/QOM/Sql1GeneratorTest.php
@@ -45,12 +45,18 @@ public function testDoubleLiteral()
public function testChildNode()
{
+ $literal = $this->generator->evalChildNode("/");
+ $this->assertSame("jcr:path LIKE '/%' AND NOT jcr:path LIKE '/%/%'", $literal);
+
$literal = $this->generator->evalChildNode("/foo/bar/baz");
$this->assertSame("jcr:path LIKE '/foo[%]/bar[%]/baz[%]/%' AND NOT jcr:path LIKE '/foo[%]/bar[%]/baz[%]/%/%'", $literal);
}
public function testDescendantNode()
{
+ $literal = $this->generator->evalDescendantNode("/");
+ $this->assertSame("jcr:path LIKE '/%'", $literal);
+
$literal = $this->generator->evalDescendantNode("/foo/bar/baz");
$this->assertSame("jcr:path LIKE '/foo[%]/bar[%]/baz[%]/%'", $literal);
}