Skip to content

fix: hidden() now strips columns whose value is NULL - #43

Merged
mychidarko merged 1 commit into
v5.xfrom
fix/hidden-null-columns
Oct 16, 2026
Merged

mychidarko merged 1 commit into
v5.xfrom
fix/hidden-null-columns

Conversation

@mychidarko

Copy link
Copy Markdown
Member

Fixes #42.

Problem

hidden() strips columns with isset($result[$item]). isset() is false for keys whose value is NULL, so any hidden column that happens to be NULL on that row is left in the result. Typical victims: reset_token, remember_token, deleted_at, email_verified_at — exactly the columns people hide.

db()->select('users')->hidden('reset_token')->first();
// → ['id' => 1, 'email' => '…', 'reset_token' => null]   ← still there

Same isset() in both the first() path (Core.php L623) and the all() path (L730).

Fix

isset($result[$item]) → array_key_exists($item, $result) in both places. No other behaviour changes; the dotted relation.column branch is untouched.

Tests

New test hidden removes fields whose value is null in tests/db.test.php (sqlite, reset_token TEXT NULL), covering first() and all(). Fails on v5.x, passes with the change.

alchemy test: 32 passed (78 assertions). alchemy lint: clean.

@mychidarko
mychidarko merged commit 44aa0ff into v5.x Oct 16, 2026
20 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.

db()->select()->hidden() returns hidden columns when they contain null

1 participant