From 207c7273f3aa872606406194bbe4e304e87ed9b6 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Fri, 25 Oct 2024 11:02:53 +0530 Subject: [PATCH] Fix hasSelects when no selects have been added Closes #742 --- src/Query/Builder.php | 2 +- tests/Unit/Query/BuilderTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 2f3c4198..3474ba9b 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -1313,7 +1313,7 @@ public function clearFilters(): static */ public function hasSelects(): bool { - return count($this->columns) > 0; + return count($this->columns ?? []) > 0; } /** diff --git a/tests/Unit/Query/BuilderTest.php b/tests/Unit/Query/BuilderTest.php index 870353c4..5476b4e1 100644 --- a/tests/Unit/Query/BuilderTest.php +++ b/tests/Unit/Query/BuilderTest.php @@ -86,6 +86,8 @@ public function test_has_selects() { $b = $this->newBuilder(); + $this->assertFalse($b->hasSelects()); + $b->select('test'); $this->assertTrue($b->hasSelects());