@@ -119,6 +119,24 @@ public function test_where_not_in(): void
119119 $ this ->assertSql ('SELECT * FROM `users` WHERE `status` NOT IN (?, ?) ' , $ b );
120120 }
121121
122+ /**
123+ * Regression: an empty IN list produces invalid SQL (`IN ()`) on
124+ * MySQL/PostgreSQL. `x IN (nothing)` is always false, so it must
125+ * compile to `1 = 0` (and NOT IN to `1 = 1`).
126+ */
127+ public function test_where_in_empty_array (): void
128+ {
129+ $ b = $ this ->builder ()->whereIn ('id ' , []);
130+ $ this ->assertSql ('SELECT * FROM `users` WHERE 1 = 0 ' , $ b );
131+ $ this ->assertSame ([], $ b ->getBindings ());
132+ }
133+
134+ public function test_where_not_in_empty_array (): void
135+ {
136+ $ b = $ this ->builder ()->whereNotIn ('id ' , []);
137+ $ this ->assertSql ('SELECT * FROM `users` WHERE 1 = 1 ' , $ b );
138+ }
139+
122140 public function test_where_null (): void
123141 {
124142 $ this ->assertSql (
@@ -160,6 +178,33 @@ public function test_where_nested_group(): void
160178 );
161179 }
162180
181+ /**
182+ * Regression: column names that collide with built-in PHP function names
183+ * (key, list, count, current, ...) were wrongly detected as callables by
184+ * is_callable(), routing them into whereNested() and triggering
185+ * "Calling key() on an object is deprecated". Only Closures are nested
186+ * groups now — a plain string is always a column name.
187+ */
188+ public function test_where_with_php_function_named_column (): void
189+ {
190+ $ b = $ this ->builder ()->where ('key ' , 'footer_settings ' );
191+ $ this ->assertSql ('SELECT * FROM `users` WHERE `key` = ? ' , $ b );
192+ $ this ->assertSame (['footer_settings ' ], $ b ->getBindings ());
193+ }
194+
195+ public function test_where_with_count_column (): void
196+ {
197+ $ b = $ this ->builder ()->where ('count ' , '> ' , 5 );
198+ $ this ->assertSql ('SELECT * FROM `users` WHERE `count` > ? ' , $ b );
199+ }
200+
201+ public function test_nested_group_still_works_with_closure (): void
202+ {
203+ // A real Closure must still produce a nested group
204+ $ b = $ this ->builder ()->where (fn ($ q ) => $ q ->where ('a ' , 1 )->orWhere ('b ' , 2 ));
205+ $ this ->assertSql ('SELECT * FROM `users` WHERE (`a` = ? OR `b` = ?) ' , $ b );
206+ }
207+
163208 public function test_where_raw (): void
164209 {
165210 $ b = $ this ->builder ()->whereRaw ('age > 18 AND active = 1 ' );
@@ -297,4 +342,4 @@ public function test_true_false_shorthands(): void
297342 $ this ->builder ()->false ('active ' ),
298343 );
299344 }
300- }
345+ }
0 commit comments