Skip to content

Commit

Permalink
fix(query-builder): use AND for multiple where statements
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreGerault committed Jul 19, 2021
1 parent 7134ea1 commit 68b5c6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AGerault/Database/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private function appendConditions(string $query): string
{
if ($this->conditions) {
$conditions = implode(
', ',
' AND ',
array_map(
function ($name, $payload) {
$value = $payload['value'] ?? ":{$name}";
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Database/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function () {
->delete();

expect($query->from('posts')->toSQL())->toBeString()->toBe(
'DELETE FROM posts WHERE name = :name, slug = :slug'
'DELETE FROM posts WHERE name = :name AND slug = :slug'
);
}
);
Expand Down Expand Up @@ -201,7 +201,7 @@ function () {

expect($query->toSQL())
->toBeString()
->toBe('UPDATE posts SET title = :title, slug = :slug WHERE title = :title, slug = :slug');
->toBe('UPDATE posts SET title = :title, slug = :slug WHERE title = :title AND slug = :slug');
}
);

Expand Down

0 comments on commit 68b5c6b

Please sign in to comment.