Skip to content
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

Exception when persisting class unlisted in disciminator map (Issue 867) #1887

Merged
merged 3 commits into from
Nov 30, 2018

Conversation

watari
Copy link
Contributor

@watari watari commented Oct 30, 2018

Q A
Type feature/improvement
BC Break yes
Fixed issues #867

Summary

Updated persisting logic to throw exception of class is not listed in discriminator map.

There is no new tests is added since library have a set of old tests that is cover most of the cases.

Right now exception message contain information only about unlisted class without parent class since in the places of the checks I don't find a way of extracting parent class info.

@watari watari force-pushed the issue_867 branch 2 times, most recently from a46ec90 to fb84eea Compare October 30, 2018 19:05
@alcaeus alcaeus self-requested a review November 1, 2018 20:34
lib/Doctrine/ODM/MongoDB/DocumentManager.php Outdated Show resolved Hide resolved
lib/Doctrine/ODM/MongoDB/DocumentManager.php Outdated Show resolved Hide resolved
lib/Doctrine/ODM/MongoDB/DocumentManager.php Outdated Show resolved Hide resolved
@malarzm
Copy link
Member

malarzm commented Nov 1, 2018

This logic forbid use of empty discriminator map. Now all embedded and referenced documents must have target document or discriminator map.

This answers one of my comments :) I don't think we should go that far, not specifying discriminatorMap is IMO very useful and the only strictness we should introduce is, as per #867, throwing an exception if user has opted in for using a map AND document being persisted is not listed there.

@watari
Copy link
Contributor Author

watari commented Nov 4, 2018

This logic forbid use of empty discriminator map. Now all embedded and referenced documents must have target document or discriminator map.

This answers one of my comments :) I don't think we should go that far, not specifying discriminatorMap is IMO very useful and the only strictness we should introduce is, as per #867, throwing an exception if user has opted in for using a map AND document being persisted is not listed there.

@malarzm , I really gone to far with strictness). I will decrease checks for making discriminatorMap optional. Can you, please, check my answers to your comments?

@malarzm
Copy link
Member

malarzm commented Nov 5, 2018

@watari I think I've answered all questions, but I think that the best course of action would be to create this PR once again and only introducing the exception. It should be easier than reverting all changes that will no longer be needed :)

@watari watari force-pushed the issue_867 branch 2 times, most recently from 804b1c2 to b577752 Compare November 9, 2018 05:56
@watari
Copy link
Contributor Author

watari commented Nov 9, 2018

@malarzm , it was not so hard to revert partially changes and introduce only exception in this PR). Also I updated PR description. Can you, please, check all again?

…iscriminator map from ClassMetadata class. Replaced tests and docs class name literals by `::class` constants. Updated docs according to new behaviour with unregistered classes.
@watari
Copy link
Contributor Author

watari commented Nov 19, 2018

@alcaeus , @malarzm , is there will be any other remarks about PR? All previous remarks is already implemented.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from documentation wording, this looks good! Great work @watari!

docs/en/reference/annotations-reference.rst Outdated Show resolved Hide resolved
@alcaeus alcaeus self-assigned this Nov 28, 2018
@alcaeus alcaeus added this to the 2.0.0 milestone Nov 28, 2018
@watari
Copy link
Contributor Author

watari commented Nov 28, 2018

Updated docs according to suggestions

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @watari! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants