Conversation
alganet
commented
Mar 26, 2026
- Mapper::flush() resets pending queue on failure, preventing cascading errors across requests in long-running runtimes (Swoole, ReactPHP)
- Db::executeStatement() resets SQL state before execute, not after, so failures don't corrupt subsequent queries
- extractAndOperateCompositions() converts spec keys via Style::realProperty() to match DB column names after extractColumns() conversion
- Composite joins now emit explicit ON clauses instead of relying on implicit FK inference
- Composite entities no longer carry child PKs (commentId removed)
- checkNewIdentity() casts lastInsertId to int for typed properties
- Removed unused $parentCols parameter from insertCompositionChildren()
- All test stubs use typed properties and pure entity tree pattern
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #109 +/- ##
============================================
+ Coverage 98.32% 98.68% +0.35%
- Complexity 172 182 +10
============================================
Files 4 4
Lines 419 456 +37
============================================
+ Hits 412 450 +38
+ Misses 7 6 -1 ☔ 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 updates the ORM mapping behavior to support “pure entity tree” relationships (object references instead of FK scalar fields) and hardens runtime safety by ensuring internal mapper/DB state is reset after failures—important for long-running PHP runtimes (e.g., Swoole/ReactPHP).
Changes:
- Reset
Mapperpending state onflush()failure; resetDbSQL state before executing statements. - Rework composite handling: DB-column name normalization, explicit
JOIN ... ON ...clauses, and composition child INSERT/UPDATE behavior. - Update test stubs and mapper tests to use typed properties and pure entity tree relations (no embedded child PK fields).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Mapper.php |
Adds reset-on-failure for flush(), reworks composite extraction/update, adds composition child inserts, normalizes extracted column keys, and adds explicit composite join ON clauses. |
src/Db.php |
Resets SQL builder state before statement execution to prevent cross-query contamination after failures. |
tests/MapperTest.php |
Adds/updates tests for pending reset, composite collision precedence, skipping cascades for uninitialized relations, and updated “id not initialized” assertions. |
tests/Stubs/Postcomment.php |
Converts stub to typed properties and pure entity tree relation (Author $author). |
tests/Stubs/PostCategory.php |
Converts to typed entity relations (Post $post, Category $category) instead of FK scalar fields. |
tests/Stubs/Post.php |
Converts to typed properties and replaces comment_id with Comment $comment. |
tests/Stubs/OtherEntity/Post.php |
Tightens typing and removes FK scalar handling in favor of Author $author. |
tests/Stubs/OtherEntity/Comment.php |
Converts FK scalar to relation (Post $post) and tightens typing. |
tests/Stubs/OtherEntity/Author.php |
Tightens typing for id/name accessors. |
tests/Stubs/Issues.php |
Changes id to typed int. |
tests/Stubs/Issue.php |
Changes id to typed int. |
tests/Stubs/Improvement.php |
Changes id to typed int. |
tests/Stubs/Comment.php |
Converts post to typed Post relation and tightens typing. |
tests/Stubs/Category.php |
Converts to typed properties and replaces category_id with Category $category relation. |
tests/Stubs/Bug.php |
Changes id to typed int. |
tests/Stubs/Author.php |
Changes id/name to typed non-nullable properties. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Mapper::flush() resets pending queue on failure, preventing cascading errors across requests in long-running runtimes (Swoole, ReactPHP) - Db::executeStatement() resets SQL state before execute, not after, so failures don't corrupt subsequent queries - extractAndOperateCompositions() converts spec keys via Style::realProperty() to match DB column names after extractColumns() conversion - Composite joins now emit explicit ON clauses instead of relying on implicit FK inference - Composite entities no longer carry child PKs (commentId removed) - checkNewIdentity() casts lastInsertId to int for typed properties - Removed unused $parentCols parameter from insertCompositionChildren() - All test stubs use typed properties and pure entity tree pattern