Skip to content

Fix/where column name collision#55

Merged
benkhalife merged 2 commits into
mainfrom
fix/where-column-name-collision
Jun 11, 2026
Merged

Fix/where column name collision#55
benkhalife merged 2 commits into
mainfrom
fix/where-column-name-collision

Conversation

@benkhalife

Copy link
Copy Markdown
Member

No description provided.

where() used is_callable($column) to detect nested-group closures, but
column names that collide with built-in PHP functions (key, list, count,
current, ...) made is_callable() return true. Such columns were wrongly
routed into whereNested(), triggering 'Calling key() on an object is
deprecated' on PHP 8.1+.

Detect nested groups with $column instanceof \Closure instead. A plain
string is always a column name now.

Also align first()/find() to return null (not false) when no row matches,
matching Model::find() and supporting ModelBuilder's ?Model return type.

Adds regression tests for key/count/list column names and verifies that
Closure-based nested groups still work.

Fixes #53
…rrays

is_callable() returns true for strings matching built-in PHP function
names (key, list, count, ...), so Collection::contains() and Builder::join()
wrongly treated such column names as callbacks. Detect \Closure instead.
whereExists() switched to \Closure too for consistency. Same root cause as
the earlier where() fix.

Empty whereIn([])/whereNotIn([]) compiled to 'IN ()', a syntax error on
MySQL and PostgreSQL that silently passed on SQLite. Now compiles to
'1 = 0' (empty IN, always false) and '1 = 1' (empty NOT IN, always true),
valid on all drivers.

Adds regression tests for function-named columns, contains() variants, and
empty IN/NOT IN arrays.

Fixes #54
@benkhalife benkhalife merged commit b5d23af into main Jun 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant