-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Exporters should only inspect joinColumns
for owning side in bi-directional OneToOne
#5858
Conversation
cd8a009
to
9291dfe
Compare
YamlExporter
should only inspect joinColumns
for owning side in bi-directional OneToOnejoinColumns
for owning side in bi-directional OneToOne
👍 |
1 similar comment
👍 |
@@ -114,10 +114,11 @@ public function exportClassMetadata(ClassMetadataInfo $metadata) | |||
|
|||
if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { | |||
$method = 'mapOneToOne'; | |||
$joinColumns = $associationMapping['isOwningSide'] === true ? $associationMapping['joinColumns'] : array(); |
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.
[]
can be used here. Variable also not needed (can directly be inlined into line 121). === true
also not needed, as the value is boolean
…ectional OneToOne rebased commits: - Added test case for bi-directional OneToOne in YamlExporter - Only inspect joinColumns for owning side in bi-directional OneToOne in YamlExporter - Adding bi-directional test case without joinColumn to XmlExporter test - Same testcase also applied to PhpExporter - Fixing bi-directional issue in PhpExporter when inspecting joinColumns index - Implemented @Ocramius suggestions
9351ffc
to
ea788fb
Compare
…umn-on-owning-association-side' Close #5858
…umn-on-owning-association-side-2.5' into 2.5 Close #5858
@Ocramius There are a few test failures that I cannot explain though: https://travis-ci.org/doctrine/doctrine2/builds/136120071 |
Yeah, they are unrelated to this change though. Will have to check them |
After having run the YamlExporter in one of our projects there was a weird behavior when a bi-directional OneToOne association was defined.
I managed to replicate the behavior with adding an inversed bi-directional mapping to the test metadata:
Doctrine.Tests.ORM.Tools.Export.User.dcm.yml
So the problem is that the
joinColumn
array index is not set for the inversed side but will still be inspected. After applying the check for$associationMapping['isOwningSide'] === true ? $associationMapping['joinColumns'] : array();
the export works as expected.Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml
EDIT
Same applies to the
PhpExporter
when duplicating the test case to the test metadata: