Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for passing a closure to select(), it should return the
list of fields to be selected
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -134,6 +134,20 @@ public function testSelectFieldsOnly() { | ||
$this->assertEquals([3, 6], $result->fetch()); | $this->assertEquals([3, 6], $result->fetch()); | ||
} | } | ||
|
|
||
/** | |||
* Tests that it is possible to pass a closure as fields in select() | |||
* | |||
* @return void | |||
*/ | |||
public function testSelectClosure() { | |||
$query = new Query($this->connection); | |||
$result = $query->select(function($q) use ($query) { | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lorenzo
Author
Member
|
|||
$this->assertSame($query, $q); | |||
return ['1 + 2', '1 + 5']; | |||
})->execute(); | |||
$this->assertEquals([3, 6], $result->fetch()); | |||
} | |||
|
|||
/** | /** | ||
* Tests it is possible to select fields from tables with no conditions | * Tests it is possible to select fields from tables with no conditions | ||
* | * | ||
|
How is this working? The Closure never got bound to the test case.