Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens the Model ORM’s behavior around “no row” edge cases and no-op writes, and adds tests to lock in the new semantics. It also ensures DB-level caches are reset correctly on reconnect.
Changes:
- Make single-record fetch APIs (
getById,first,last,fetchOneWhere) returnnullwhen no rows are found, and adjustfetchWhereaccordingly. - Handle inserts with no dirty fields by issuing
DEFAULT VALUES/() VALUES ()SQL depending on the driver, and makeupdate()returnfalseinstead of running a no-opUPDATEwhen there are no dirty fields. - Reset identifier-quote, statement cache, and table column cache on
connectDb(), and add PHPUnit tests covering missing fetches and empty insert/update behavior forCategory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Model/Model.php | Adjusts connection setup to reset internal caches; updates fetch helpers to return null for missing records; safely handles insert/update when there are no dirty fields; updates return types/docblocks to match new behavior. |
| tests/Model/CategoryTest.php | Extends category integration tests to assert non-null result from getById, verify fetchOneWhere returns null when no row exists, confirm inserts with no dirty fields still create a row and set id, and assert update(false) returns false when there are no dirty fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing