Skip to content

Commit

Permalink
Wrap columns in whereRowValues() (#25179)
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir authored and taylorotwell committed Aug 11, 2018
1 parent 2aff496 commit 4643442
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ protected function whereNotExists(Builder $query, $where)
*/
protected function whereRowValues(Builder $query, $where)
{
$columns = $this->columnize($where['columns']);

$values = $this->parameterize($where['values']);

return '('.implode(', ', $where['columns']).') '.$where['operator'].' ('.$values.')';
return '('.$columns.') '.$where['operator'].' ('.$values.')';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2631,15 +2631,15 @@ public function testWhereRowValues()
{
$builder = $this->getBuilder();
$builder->select('*')->from('orders')->whereRowValues(['last_update', 'order_number'], '<', [1, 2]);
$this->assertEquals('select * from "orders" where (last_update, order_number) < (?, ?)', $builder->toSql());
$this->assertEquals('select * from "orders" where ("last_update", "order_number") < (?, ?)', $builder->toSql());

$builder = $this->getBuilder();
$builder->select('*')->from('orders')->where('company_id', 1)->orWhereRowValues(['last_update', 'order_number'], '<', [1, 2]);
$this->assertEquals('select * from "orders" where "company_id" = ? or (last_update, order_number) < (?, ?)', $builder->toSql());
$this->assertEquals('select * from "orders" where "company_id" = ? or ("last_update", "order_number") < (?, ?)', $builder->toSql());

$builder = $this->getBuilder();
$builder->select('*')->from('orders')->whereRowValues(['last_update', 'order_number'], '<', [1, new Raw('2')]);
$this->assertEquals('select * from "orders" where (last_update, order_number) < (?, 2)', $builder->toSql());
$this->assertEquals('select * from "orders" where ("last_update", "order_number") < (?, 2)', $builder->toSql());
$this->assertEquals([1], $builder->getBindings());
}

Expand Down

0 comments on commit 4643442

Please sign in to comment.