Skip to content

Commit

Permalink
Fix changes from laravel/framework@1d58ce1
Browse files Browse the repository at this point in the history
  • Loading branch information
jfelder committed Jan 6, 2016
1 parent c4b9b4b commit 38c96ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/Jfelder/OracleDB/Query/Grammars/OracleGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ protected function compileUnions(Builder $query)
return ltrim($sql);
}

/**
* Compile an exists statement into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @return string
*/
public function compileExists(Builder $query)
{
$select = $this->compileSelect($query);

return "select t2.\"rn\" as {$this->wrap('exists')} from ( select rownum AS \"rn\", t1.* from ({$select}) t1 ) t2 where t2.\"rn\" between 1 and 1";
}


/**
* Compile the lock into SQL.
*
Expand Down
3 changes: 1 addition & 2 deletions tests/OracleDBQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ public function testAggregateFunctions()
$this->assertEquals(1, $results);

$builder = $this->getOracleBuilder();
$builder->getConnection()->shouldReceive('select')->once()->with('select t2.* from ( select rownum AS "rn", t1.* from (select count(*) as aggregate from "users") t1 ) t2 where t2."rn" between 1 and 1', [], true)->andReturn([['aggregate' => 1]]);
$builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function ($builder, $results) { return $results; });
$builder->getConnection()->shouldReceive('select')->once()->with('select t2."rn" as "exists" from ( select rownum AS "rn", t1.* from (select * from "users") t1 ) t2 where t2."rn" between 1 and 1', [], true)->andReturn([["exists" => 1]]);
$results = $builder->from('users')->exists();
$this->assertTrue($results);

Expand Down

0 comments on commit 38c96ed

Please sign in to comment.