Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function where(WhereCondition|array|WhereGroup $where): static
*/
public function getWhere(): WhereGroup|null
{
if ($this->where) {
if ($this->where && $this->where->count() > 0) {
return $this->where;
}

Expand Down Expand Up @@ -192,4 +192,4 @@ public function getLimit(): ?Limit
{
return $this->limit;
}
}
}
10 changes: 10 additions & 0 deletions test/tests/SQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public function testSelect()
$this->assertEquals("SELECT * FROM `test`", $this->sql->generate($query));
}

public function testSelectEmptyWhere()
{
$query = new SelectQuery(
new WhereGroup(),
);
$query->modelClassName = TestModel::class;

$this->assertEquals("SELECT * FROM `test`", $this->sql->generate($query));
}

public function testSelectWhereCondition()
{
$query = new SelectQuery(
Expand Down
Loading