From 44fce93101ae66da7724f07c3b9ae520092f0ee3 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 11 Sep 2020 14:54:39 +0100 Subject: [PATCH] fix: use deleteByQuery to allow multiple deletes --- src/Connection.php | 2 +- src/QueryBuilder.php | 2 +- src/QueryGrammar.php | 15 +-------------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 17d7293..d6d1f0d 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -165,7 +165,7 @@ public function delete($query, $bindings = []) return $this->run( $query, $bindings, - Closure::fromCallable([$this->connection, 'delete']) + Closure::fromCallable([$this->connection, 'deleteByQuery']) ); } diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index a400bed..61291f4 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -759,7 +759,7 @@ public function delete($id = null): bool $result = $this->connection->delete($this->grammar->compileDelete($this)); - return !empty($result['found']); + return !empty($result['deleted']); } public function __call($method, $parameters) diff --git a/src/QueryGrammar.php b/src/QueryGrammar.php index 38e913c..3719e67 100644 --- a/src/QueryGrammar.php +++ b/src/QueryGrammar.php @@ -1133,20 +1133,7 @@ public function compileInsert(Builder $builder, array $values): array */ public function compileDelete(Builder $builder): array { - $params = [ - 'index' => $builder->from . $this->indexSuffix, - 'id' => (string) $builder->wheres[0]['value'] - ]; - - if ($routing = $builder->getRouting()) { - $params['routing'] = $routing; - } - - if ($parentId = $builder->getParentId()) { - $params['parent'] = $parentId; - } - - return $params; + return $this->compileSelect($builder); } /**