diff --git a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php index bc0420db4e61..bc686e3fe644 100755 --- a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php @@ -400,9 +400,9 @@ protected function compileDeleteWithJoins($query, $table) return $this->wrapTable($join->table); })->implode(', '); - $where = count($query->wheres) > 0 ? ' '.$this->compileUpdateWheres($query) : ''; + $where = $this->compileUpdateWheres($query); - return trim("delete from {$table}{$using}{$where}"); + return trim("delete from {$table}{$using} {$where}"); } /** diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 341b1bbd0735..fa0c4ea65367 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -2183,6 +2183,11 @@ public function testDeleteWithJoinMethod() })->where('name', 'baz') ->delete(); $this->assertEquals(1, $result); + + $builder = $this->getPostgresBuilder(); + $builder->getConnection()->shouldReceive('delete')->once()->with('delete from "users" USING "contacts" where "users"."id" = "contacts"."id"', [])->andReturn(1); + $result = $builder->from('users')->join('contacts', 'users.id', '=', 'contacts.id')->delete(); + $this->assertEquals(1, $result); } public function testTruncateMethod()