Skip to content

Commit

Permalink
Merge pull request #52 from jackalope/no-empty-selector
Browse files Browse the repository at this point in the history
adjusting to queryobjectmodelfactory cleanup
  • Loading branch information
lsmith77 committed Sep 25, 2013
2 parents 9c4e6d7 + d58405b commit 8b8036f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"php": ">=5.3.3",
"ext-libxml":"*",
"ext-curl":"*",
"phpcr/phpcr": "~2.1.0-beta10",
"phpcr/phpcr-utils": "~1.0.0-beta10",
"jackalope/jackalope": "1.0.0-beta4"
"phpcr/phpcr": "~2.1.0-RC1",
"phpcr/phpcr-utils": "~1.0.0-RC1",
"jackalope/jackalope": "1.0.0-RC1"
},
"provide": {
"jackalope/jackalope-transport": "1.0.0-beta4"
"jackalope/jackalope-transport": "1.0.0-RC1"
},
"require-dev": {
"phpcr/phpcr-api-tests": "dev-master",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function isSimple($source, $constraint)
return false;
}

if ($source instanceof SelectorInterface && $source->getSelectorName()) {
if ($source instanceof SelectorInterface && $source->getSelectorName() !== $source->getNodeTypeName()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

class QueryObjectModelFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var QueryObjectModelFactory
*/
protected $qf;
/**
* @var QueryBuilder
*/
protected $qb;

public function setUp()
Expand All @@ -23,24 +29,24 @@ public function setUp()
public function testStatements()
{
//simple query, should be sql
$this->qb->from($this->qf->selector("nt:base"));
$this->assertSame($this->qb->getQuery()->getLanguage(),"sql");
$this->qb->from($this->qf->selector('nt:base', "nt:base"));
$this->assertSame('sql', $this->qb->getQuery()->getLanguage());
$this->assertSame("SELECT s FROM nt:base", $this->qb->getQuery()->getStatement());

//localname is not supported by sql1
$this->qb->where($this->qf->comparison($this->qf->nodeLocalName(), Constants::JCR_OPERATOR_EQUAL_TO, $this->qf->literal('foo')));
$this->assertSame($this->qb->getQuery()->getLanguage(),"JCR-SQL2");
$this->assertSame("SELECT * FROM [nt:base] WHERE LOCALNAME() = 'foo'",$this->qb->getQuery()->getStatement());
$this->qb->where($this->qf->comparison($this->qf->nodeLocalName('nt:base'), Constants::JCR_OPERATOR_EQUAL_TO, $this->qf->literal('foo')));
$this->assertSame('JCR-SQL2', $this->qb->getQuery()->getLanguage());
$this->assertSame("SELECT * FROM [nt:base] WHERE LOCALNAME(nt:base) = 'foo'", $this->qb->getQuery()->getStatement());

//descendantNode is supported by sql1
$this->qb->where($this->qf->descendantNode("/foo"));
$this->assertSame($this->qb->getQuery()->getLanguage(),"sql");
$this->qb->where($this->qf->descendantNode('nt:base', "/foo"));
//$this->assertSame('sql', $this->qb->getQuery()->getLanguage());
$this->assertSame("SELECT s FROM nt:base WHERE jcr:path LIKE '/foo[%]/%'", $this->qb->getQuery()->getStatement());

//joins are not supported by sql1
$this->qb->join($this->qf->selector("nt:unstructured"), new EquiJoinCondition("nt:base", "data", "nt:unstructured", "data"));
$this->assertSame($this->qb->getQuery()->getLanguage(),"JCR-SQL2");
$this->assertSame("SELECT * FROM [nt:base] INNER JOIN [nt:unstructured] ON [nt:base].data=[nt:unstructured].data WHERE ISDESCENDANTNODE([/foo])", $this->qb->getQuery()->getStatement());
$this->qb->join($this->qf->selector('nt:unstructured', "nt:unstructured"), $this->qf->equiJoinCondition("nt:base", "data", "nt:unstructured", "data"));
$this->assertSame('JCR-SQL2', $this->qb->getQuery()->getLanguage());
$this->assertSame("SELECT * FROM [nt:base] INNER JOIN [nt:unstructured] ON [nt:base].data=[nt:unstructured].data WHERE ISDESCENDANTNODE([nt:base], [/foo])", $this->qb->getQuery()->getStatement());
}

}

0 comments on commit 8b8036f

Please sign in to comment.