Skip to content

Commit

Permalink
[5.6] Added support for MySQL's "sounds like" operator (#23351)
Browse files Browse the repository at this point in the history
* Added support for MySQL's sounds-like operator

* Added a test
  • Loading branch information
mgrinspan authored and taylorotwell committed Mar 1, 2018
1 parent 1045fc5 commit 075ba07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

class MySqlGrammar extends Grammar
{
/**
* The grammar specific operators.
*
* @var array
*/
protected $operators = ['sounds like'];

/**
* The components that make up a select clause.
*
Expand Down
8 changes: 8 additions & 0 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,14 @@ public function testSqlServerLimitsAndOffsets()
$this->assertEquals('select * from (select *, row_number() over (order by [email] desc) as row_num from [users]) as temp_table where row_num between 11 and 20', $builder->toSql());
}

public function testMySqlSoundsLikeOperator()
{
$builder = $this->getMySqlBuilder();
$builder->select('*')->from('users')->where('name', 'sounds like', 'John Doe');
$this->assertEquals('select * from `users` where `name` sounds like ?', $builder->toSql());
$this->assertEquals(['John Doe'], $builder->getBindings());
}

public function testMergeWheresCanMergeWheresAndBindings()
{
$builder = $this->getBuilder();
Expand Down

0 comments on commit 075ba07

Please sign in to comment.