@@ -114,6 +114,68 @@ public function testQueryJoin()
114114 $ this ->assertEquals (array (999 ), $ vals );
115115 }
116116
117+ public function testQueryLeftJoin ()
118+ {
119+ /** @var $query QueryInterface */
120+ $ query = $ this ->sharedFixture ['qm ' ]->createQuery (
121+ 'SELECT file.[jcr:name], target.longNumberToCompare
122+ FROM [nt:file] AS file
123+ LEFT OUTER JOIN [nt:unstructured] AS target
124+ ON ISDESCENDANTNODE(target, file)
125+ ' ,
126+ QueryInterface::JCR_SQL2
127+ );
128+
129+ $ this ->assertInstanceOf ('\PHPCR\Query\QueryInterface ' , $ query );
130+ $ result = $ query ->execute ();
131+ $ this ->assertInstanceOf ('\PHPCR\Query\QueryResultInterface ' , $ result );
132+ $ vals = array ();
133+ foreach ($ result ->getRows () as $ row ) {
134+ $ vals [basename ($ row ->getPath ('file ' ))] = $ row ->getValue ('target.longNumberToCompare ' );
135+ }
136+
137+ // We get 9 results (idExample comes back multiple times because of the join)
138+ $ this ->assertCount (9 , $ result ->getRows ());
139+ $ this ->assertEquals (array (
140+ 'index.txt ' => null ,
141+ 'idExample ' => null ,
142+ 'numberPropertyNode ' => null ,
143+ 'NumberPropertyNodeToCompare1 ' => 2 ,
144+ 'NumberPropertyNodeToCompare2 ' => 10 ,
145+ ), $ vals );
146+ }
147+
148+ public function testQueryRightJoin ()
149+ {
150+ /** @var $query QueryInterface */
151+ $ query = $ this ->sharedFixture ['qm ' ]->createQuery (
152+ 'SELECT file.[jcr:name], target.stringToCompare
153+ FROM [nt:unstructured] AS target
154+ RIGHT OUTER JOIN [nt:file] AS file
155+ ON ISDESCENDANTNODE(target, file)
156+ ' ,
157+ QueryInterface::JCR_SQL2
158+ );
159+
160+ $ this ->assertInstanceOf ('\PHPCR\Query\QueryInterface ' , $ query );
161+ $ result = $ query ->execute ();
162+ $ this ->assertInstanceOf ('\PHPCR\Query\QueryResultInterface ' , $ result );
163+ $ vals = array ();
164+ foreach ($ result ->getRows () as $ row ) {
165+ $ vals [basename ($ row ->getPath ('file ' ))] = $ row ->getValue ('target.stringToCompare ' );
166+ }
167+
168+ // We get 9 results (idExample comes back multiple times because of the join)
169+ $ this ->assertCount (9 , $ result ->getRows ());
170+ $ this ->assertEquals (array (
171+ 'index.txt ' => null ,
172+ 'idExample ' => null ,
173+ 'numberPropertyNode ' => null ,
174+ 'NumberPropertyNodeToCompare1 ' => '2 ' ,
175+ 'NumberPropertyNodeToCompare2 ' => '10 ' ,
176+ ), $ vals );
177+ }
178+
117179 public function testQueryJoinReference ()
118180 {
119181 /** @var $query QueryInterface */
0 commit comments