Conversation
…nd deleteRelationship - Change getSupportForRelationships() to return true, enabling all relationship tests - Fix deleteRelationship() ONE_TO_ONE to handle side parameter correctly (matching MariaDB) - Fix deleteRelationship() ONE_TO_MANY/MANY_TO_ONE to unset correct fields per side - Fix deleteRelationship() MANY_TO_MANY to use sequence-based junction collection naming and side parameter (matching MariaDB pattern) Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
- Fix updateRelationship: pass raw collection ID to getDocument for M2M metadata lookup - Fix updateRelationship: add guards to prevent $rename when old key == new key - Fix deleteRelationship: pass raw collection ID to getDocument for M2M metadata lookup - Fix replaceChars: handle all $-prefixed user field names, not just known attributes - Fix castingAfter: ensure null relationship attributes exist in documents returned from MongoDB Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
- Escape $ prefix and dots in MongoDB field names (replaceChars, buildFilter, deleteRelationship, updateRelationship) - Fix renameIndex to search by $id instead of key field - Add ensureRelationshipDefaults to set null for missing stored relationship attributes - Add escapeMongoFieldName helper for consistent field name escaping Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
…attributes - Fix endsWith/startsWith regex: remove double-escaping of backslashes from preg_quote - Add escapeQueryAttributes to handle dots in query attributes vs nested object paths - Only escape $-prefixed attributes in buildFilter (not nested object paths) - Add collection-aware attribute escaping in find() and count() methods - All 606 MongoDB tests now pass (0 failures, 0 errors, 4 skips from @Depends) Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
Move the $index null check before deleteIndex() call to prevent deleting an index that wasn't found in metadata. Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
Skip the test when getSupportForAttributes() is false (schemaless mode) because schemaless databases allow unknown attributes by design, so Structure validation won't reject the 'name' attribute. Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
The null check for $index at line 1125 guarantees it's non-null, making the $index && condition at line 1134 always true. PHPStan level 7 flagged this as "Left side of && is always true". Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
…nships' into fix-mongo-relationships
📝 WalkthroughWalkthroughThis PR upgrades the Docker environment from PHP 8.3 to 8.4 with updated extensions (Redis, Swoole) and implements MongoDB driver build fallback. The primary change enables relationship support in the MongoDB adapter with comprehensive update/delete logic, field escaping for Mongo compatibility, and null population for missing relationship fields. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.gitignore:
- Line 1: The .gitignore was stripped to only "vendor/" which can cause
accidental commits of IDE and OS artifacts; restore the common ignore entries by
adding back .idea/, .DS_Store, mock.json, and data-tests.php (or explicitly
document that relying on a global gitignore is intentional) so contributors
don't commit editor or macOS metadata; update the .gitignore file to include
those patterns and commit the change.
In `@src/Database/Adapter/Mongo.php`:
- Around line 828-845: The many-to-many branch in updateRelationship (in
src/Database/Adapter/Mongo.php) builds the junction name as
collectionDoc.sequence + relatedCollectionDoc.sequence but ignores the $side
parameter, causing wrong junction selection when called from the child side;
modify the junction computation in updateRelationship to mirror
deleteRelationship / Database::getJunctionCollection logic by swapping the order
of collectionDoc and relatedCollectionDoc (or their sequences) when $side
indicates the child/context flip so the $junction variable matches the same
naming convention used elsewhere before performing the update/rename operations.
🧹 Nitpick comments (1)
Dockerfile (1)
36-45: Good resilience pattern for the MongoDB driver build.The pecl-first-then-source-fallback approach is solid for handling Alpine compatibility issues. Minor note: the
--recurse-submodulesflag ongit clonealready initializes submodules, so the subsequentgit submodule update --init --recursiveon line 39 is redundant (but harmless).Optional: remove redundant submodule init
|| (git clone --depth 1 --branch $PHP_MONGODB_VERSION --recurse-submodules https://github.com/mongodb/mongo-php-driver.git /tmp/mongodb \ && cd /tmp/mongodb \ - && git submodule update --init --recursive \ && phpize \
Summary by CodeRabbit
New Features
Bug Fixes
Chores