Skip to content

fix: treat a false row from PDO as no record - #10

Merged
tyrsson merged 4 commits into
0.1.xfrom
fix/no-row-returns-null
Oct 3, 2026
Merged

tyrsson merged 4 commits into
0.1.xfrom
fix/no-row-returns-null

Conversation

@tyrsson

@tyrsson tyrsson commented Oct 3, 2026

Copy link
Copy Markdown
Member

AbstractDbValidator::query() returned $statement->execute()?->current(). The PDO result's current() returns false when there are no rows, and NoRecordExists tests !== null, so it reported "A record matching the input was found" for a value that does not exist (RecordExists uses a falsy check and was unaffected).

query() now returns null for false, matching its documented contract. Regression test added: a result whose current() is false is valid for NoRecordExists. It fails without the source change (verified).

Found by running NoRecordExists against a real MySQL database: an existing value returned the row, a nonexistent one returned false.

composer test: 35 tests, 50 assertions, OK.

Signed-off-by: Joey Smith <jsmith@webinertia.net>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
@tyrsson
tyrsson merged commit 9f8131a into 0.1.x Oct 3, 2026
18 checks passed
@tyrsson
tyrsson deleted the fix/no-row-returns-null branch October 3, 2026 12:56
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