Skip to content

Commit

Permalink
Merge pull request #104 from designmynight/deleteByQuery
Browse files Browse the repository at this point in the history
fix: use deleteByQuery to allow multiple deletes
  • Loading branch information
jmosul authored Sep 11, 2020
2 parents 91dfe54 + 44fce93 commit deb64c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function delete($query, $bindings = [])
return $this->run(
$query,
$bindings,
Closure::fromCallable([$this->connection, 'delete'])
Closure::fromCallable([$this->connection, 'deleteByQuery'])
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,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)
Expand Down
15 changes: 1 addition & 14 deletions src/QueryGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit deb64c3

Please sign in to comment.