Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/PHPCR/Util/Console/Command/QueryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
$query->setOffset($offset);
}

$output->writeln(sprintf('<info>Executing, language:</info> %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() .'):');
foreach ($row as $column => $value) {
$output->writeln("$column: $value");
}
}
$output->writeln(sprintf('<info>%.2f seconds</info>', $elapsed));

return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions src/PHPCR/Util/QOM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
10 changes: 7 additions & 3 deletions src/PHPCR/Util/QOM/Sql1Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPCR/Tests/Util/QOM/Sql1GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down