From 464344299c8d60f41e01e891f6854f28799e1836 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Sat, 11 Aug 2018 07:37:06 +0200 Subject: [PATCH] Wrap columns in whereRowValues() (#25179) --- src/Illuminate/Database/Query/Grammars/Grammar.php | 4 +++- tests/Database/DatabaseQueryBuilderTest.php | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Query/Grammars/Grammar.php b/src/Illuminate/Database/Query/Grammars/Grammar.php index b9e002b2b9b2..eafc2d6e423f 100755 --- a/src/Illuminate/Database/Query/Grammars/Grammar.php +++ b/src/Illuminate/Database/Query/Grammars/Grammar.php @@ -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.')'; } /** diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index f150cec20184..1106423701b9 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -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()); }