-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hybrid support for MorphToMany relationship #2690
Merged
GromNaN
merged 20 commits into
mongodb:4.1
from
hans-thomas:add-hybrid-support-to-morph-to-many
Dec 11, 2023
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ebc193f
Add hybrid support to MorphToMany;
hans-thomas 7983a59
Add test for hybrid MorphToMany;
hans-thomas 95f35d7
Add support for hybrid MorphedByMany;
hans-thomas f3d8cd3
Add test for hybrid MorphedByMany;
hans-thomas 0309791
apply phpcbf formatting
hans-thomas 3432981
WIP
hans-thomas 33716b5
Add hybrid MorphToMany support;
hans-thomas 77f56b7
Add test for hybrid MorphToMany;
hans-thomas 2c57ebe
Merge branch 'add-hybrid-support-to-morph-to-many' of github.com:hans…
hans-thomas 065d14a
WIP
hans-thomas aad84cc
apply phpcbf formatting
hans-thomas 108ac9b
Update instance in attaching a model in MorphToMany;
hans-thomas f275560
Update instance in attaching a model in Inverse MorphToMany;
hans-thomas cb5778e
Create addIdToParentRelationData method to prevent repeating code;
hans-thomas 8ed3104
apply phpcbf formatting
hans-thomas b5137a0
Update phpstan-baseline.neon
hans-thomas 94688d4
WIP
hans-thomas e561201
Fix CS;
hans-thomas 48fdeaa
Merge branch '4.1' into add-hybrid-support-to-morph-to-many
hans-thomas 8440c57
Fix tests;
hans-thomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(array)
cast should not be used. If the value is anObjectId
, the result is not the one you expect.Here we know it's not a list of ids, so a simple array wrapping is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will double-check it later. thanks for the review❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ObjectId
fields are alwaysstring
. I tested this with a primary key and a custom key and a custom key was cast toObjectId
.In all cases, the
$this->parent->{$this->parentKey}
value isstring
. Your suggestion is more readable, but I don't see any bug here to open a PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's something we'll have to fix if we manage to store references as ObjectId. But there are many other hurdles to overcome, and I think this notion of "all keys are strings" is too hard-wired into Eloquent anyway.