Add PK identity map to AbstractMapper, consolidate $pending#21
Merged
alganet merged 1 commit intoRespect:masterfrom Mar 25, 2026
Merged
Add PK identity map to AbstractMapper, consolidate $pending#21alganet merged 1 commit intoRespect:masterfrom
alganet merged 1 commit intoRespect:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21 +/- ##
============================================
- Coverage 98.12% 97.58% -0.54%
- Complexity 186 206 +20
============================================
Files 16 16
Lines 427 456 +29
============================================
+ Hits 419 445 +26
- Misses 8 11 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR consolidates unit-of-work mutation tracking into a single $pending operation map and introduces a PK-indexed identity map in AbstractMapper to enable cached entity reuse on scalar primary-key fetches across backends.
Changes:
- Replace
$new/$changed/$removedregistries with a single$pending: entity → ('insert'|'update'|'delete'). - Add identity map infrastructure to
AbstractMapper(register/evict/find/clear + count helpers). - Update
InMemoryMapperto use$pendingand identity map; add tests for caching and pending operation types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/AbstractMapper.php |
Introduces $pending and identity map APIs; updates persist/remove/reset behavior accordingly. |
tests/InMemoryMapper.php |
Implements pending-based flush and identity-map-backed fetch behavior in the in-memory test mapper. |
tests/AbstractMapperTest.php |
Updates reset test for pending; adds identity map and pending operation-type tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace three SplObjectStorage mutation registries ($new, $changed, $removed)
with a single $pending mapping entity/operation ('insert'|'update'|'delete').
Add identity map infrastructure to AbstractMapper so any backend can leverage
PK-indexed entity caching:
- registerInIdentityMap() / evictFromIdentityMap() for write operations
- findInIdentityMap() for read shortcut on scalar PK lookups
- clearIdentityMap() / identityMapCount() / trackedCount() for observability
InMemoryMapper updated to use $pending and identity map throughout.
Tests added covering fetch caching, insert/delete eviction, reset behavior,
and pending operation types.
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.
Replace three SplObjectStorage mutation registries ($new, $changed, $removed) with a single $pending mapping entity/operation ('insert'|'update'|'delete').
Add identity map infrastructure to AbstractMapper so any backend can leverage PK-indexed entity caching:
InMemoryMapper updated to use $pending and identity map throughout. Tests added covering fetch caching, insert/delete eviction, reset behavior, and pending operation types.