@@ -121,4 +121,42 @@ public function testWhereNotIn()
121121
122122 //--------------------------------------------------------------------
123123
124+ public function testSubQuery ()
125+ {
126+ $ subQuery = $ this ->db ->table ('job ' )
127+ ->select ('id ' )
128+ ->where ('name ' , 'Developer ' )
129+ ->getCompiledSelect ();
130+
131+ $ jobs = $ this ->db ->table ('job ' )
132+ ->where ('id not in ( ' . $ subQuery . ') ' , null , false )
133+ ->get ()
134+ ->getResult ();
135+
136+ $ this ->assertCount (3 , $ jobs );
137+ $ this ->assertEquals ('Politician ' , $ jobs [0 ]->name );
138+ $ this ->assertEquals ('Accountant ' , $ jobs [1 ]->name );
139+ $ this ->assertEquals ('Musician ' , $ jobs [2 ]->name );
140+ }
141+
142+ //--------------------------------------------------------------------
143+
144+ public function testSubQueryAnotherType ()
145+ {
146+ $ subQuery = $ this ->db ->table ('job ' )
147+ ->select ('id ' )
148+ ->where ('name ' , 'Developer ' )
149+ ->getCompiledSelect ();
150+
151+ $ jobs = $ this ->db ->table ('job ' )
152+ ->where ('id = ( ' . $ subQuery . ') ' , null , false )
153+ ->get ()
154+ ->getResult ();
155+
156+ $ this ->assertCount (1 , $ jobs );
157+ $ this ->assertEquals ('Developer ' , $ jobs [0 ]->name );
158+ }
159+
160+ //--------------------------------------------------------------------
161+
124162}
0 commit comments