Skip to content

Commit 5e005c5

Browse files
committed
Merge pull request #107 from phpcr/selector_without_alias
Selector without alias
2 parents bd8b7e0 + d70437a commit 5e005c5

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

tests/06_Query/QueryObjectSql2Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testGetStoredQueryPath()
115115

116116
$p = $query->getStoredQueryPath();
117117
$this->assertEquals('/tests_general_query/queryNode', $p);
118-
} catch(exception $e) {
118+
} catch(\Exception $e) {
119119
//FIXME: finally?
120120
$this->sharedFixture['ie']->import('general/base');
121121
throw $e;

tests/06_Query/QuerySql2OperationsTest.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testQueryField()
3838
$this->assertEquals(array('bar'), $vals);
3939
}
4040

41-
public function testQueryFieldSomenull()
41+
public function testQueryFieldSomeNull()
4242
{
4343
/** @var $query QueryInterface */
4444
$query = $this->sharedFixture['qm']->createQuery('
@@ -68,6 +68,28 @@ public function testQueryFieldSomenull()
6868
}
6969

7070
public function testQueryFieldSelector()
71+
{
72+
/** @var $query QueryInterface */
73+
$query = $this->sharedFixture['qm']->createQuery('
74+
SELECT [nt:unstructured].foo
75+
FROM [nt:unstructured]
76+
WHERE [nt:unstructured].foo = "bar"
77+
AND ISDESCENDANTNODE([/tests_general_base])
78+
',
79+
QueryInterface::JCR_SQL2
80+
);
81+
82+
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
83+
$result = $query->execute();
84+
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result);
85+
$vals = array();
86+
foreach ($result->getRows() as $row) {
87+
$vals[] = $row->getValue('foo');
88+
}
89+
$this->assertEquals(array('bar'), $vals);
90+
}
91+
92+
public function testQueryFieldSelectorWithAlias()
7193
{
7294
/** @var $query QueryInterface */
7395
$query = $this->sharedFixture['qm']->createQuery('
@@ -90,6 +112,31 @@ public function testQueryFieldSelector()
90112
}
91113

92114
public function testQueryJoin()
115+
{
116+
/** @var $query QueryInterface */
117+
$query = $this->sharedFixture['qm']->createQuery('
118+
SELECT [nt:unstructured].longNumber
119+
FROM [nt:file]
120+
INNER JOIN [nt:unstructured]
121+
ON ISDESCENDANTNODE([nt:unstructured], [nt:file])
122+
WHERE [nt:unstructured].longNumber = 999
123+
AND ISDESCENDANTNODE([nt:file], [/tests_general_base])
124+
',
125+
QueryInterface::JCR_SQL2
126+
);
127+
128+
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
129+
$result = $query->execute();
130+
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result);
131+
$vals = array();
132+
133+
foreach($result->getRows() as $row) {
134+
$vals[] = $row->getValue('nt:unstructured.longNumber');
135+
}
136+
$this->assertEquals(array(999), $vals);
137+
}
138+
139+
public function testQueryJoinWithAlias()
93140
{
94141
/** @var $query QueryInterface */
95142
$query = $this->sharedFixture['qm']->createQuery('

0 commit comments

Comments
 (0)