fix: clarify invalid reverse one-way relationship values - #975
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe database now rejects array values on the child side of one-way one-to-one relationships. End-to-end tests cover rejected child creation and successful parent-side creation. ChangesOne-way relationship validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The changed validation and its tests cover the relevant array rejection path; no actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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 |
|
| @@ -5998,6 +5998,10 @@ private function createDocumentRelationships(Document $collection, Document $doc | |||
| try { | |||
| switch (\gettype($value)) { | |||
| case 'array': | |||
There was a problem hiding this comment.
Should this throw in case of array? Maybe should be Object (Document)?
There was a problem hiding this comment.
Yeah, it should. The child side is always invalid for one-way relationships, so arrays should hit the same error too. We only see an array here because that’s what reaches this code path.
There was a problem hiding this comment.
To be precise, this only applies to one-way one-to-one. The Document case already throws the same error. The reason its an array here is that the child key isnt treated as an attribute, so it never gets converted to a Document. 🤔
Creating a document with an array on the child side of a one-way one-to-one relationship failed with
Must be either a document ID or a document, array given., although a document or an ID is rejected from that side too. The array branch ofcreateDocumentRelationships()now reports the direction error first, as its document and ID branches and the update path already do.testCreateInvalidOneWayChildArrayValueRelationshipsits with the othertestCreateInvalid*ValueRelationshiptests and uses the object payload from the issue. It fails onmainwith the old message.Related to appwrite/appwrite#8345. Appwrite gets the fix once it requires a release that contains this change.
Summary by CodeRabbit