Skip to content

Commit 3e6e06e

Browse files
committed
Correcting subquery
1 parent f9b3cf4 commit 3e6e06e

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tests/system/Database/Live/WhereTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,13 @@ public function testWhereNotIn()
123123

124124
public function testSubQuery()
125125
{
126-
$subQuery = $this->db->table('job')->where('name', 'Developer')->getCompiledSelect();
127-
126+
$subQuery = $this->db->table('job')
127+
->select('id')
128+
->where('name', 'Developer')
129+
->getCompiledSelect();
130+
128131
$jobs = $this->db->table('job')
129-
->where('id not in (' . $subQuery . ')', null, false)
132+
->where('id not in (' . $subQuery . ')', null, false)
130133
->get()
131134
->getResult();
132135

@@ -136,12 +139,17 @@ public function testSubQuery()
136139
$this->assertEquals('Musician', $jobs[2]->name);
137140
}
138141

142+
//--------------------------------------------------------------------
143+
139144
public function testSubQueryAnotherType()
140145
{
141-
$subQuery = $this->db->table('job')->where('name', 'Developer')->getCompiledSelect();
146+
$subQuery = $this->db->table('job')
147+
->select('id')
148+
->where('name', 'Developer')
149+
->getCompiledSelect();
142150

143151
$jobs = $this->db->table('job')
144-
->where('id = (' . $subQuery . ')', null, false)
152+
->where('id = (' . $subQuery . ')', null, false)
145153
->get()
146154
->getResult();
147155

0 commit comments

Comments
 (0)