-
-
Notifications
You must be signed in to change notification settings - Fork 511
Make XSD more strict for other Document types #2766
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
base: 2.12.x
Are you sure you want to change the base?
Conversation
doctrine-mongo-mapping.xsd
Outdated
<xs:element name="reference-one" type="odm:reference-one" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="reference-many" type="odm:reference-many" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="also-load-methods" type="odm:also-load-methods" minOccurs="0" /> | ||
<xs:element name="indexes" type="odm:indexes" minOccurs="0" /> |
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.
Query result documents don't have indexes. Looking at the elements possible in a document, I think we should add lifecycle callbacks and the three discriminator elements (field, map, default value) here as well.
<xs:element name="reference-one" type="odm:reference-one" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="reference-many" type="odm:reference-many" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="also-load-methods" type="odm:also-load-methods" minOccurs="0" /> | ||
<xs:element name="indexes" type="odm:indexes" minOccurs="0" /> |
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'd have to confirm in tests, but IIRC embedded documents can be discriminated and also have lifecycle callbacks, so those elements should be added.
</xs:complexType> | ||
|
||
<xs:complexType name="mapped-superclass"> | ||
<xs:attribute name="name" type="xs:NMTOKEN" /> | ||
<xs:choice minOccurs="0" maxOccurs="unbounded"> |
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.
For mapped superclasses, we should check the inheritance logic in the mapping driver to confirm what elements are allowed. IIRC, attributes like the write concern, capped collection information, etc. is all inherited to documents, so we may want to add it here as well.
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.
LGTM. Thank you for taking the time to dig into what elements and attributes are valid for which document types.
Summary
The goal of this change is to detect earlier when an XML attribute is used while it's not supported by Doctrine ODM.
BC Break: previously, the XSD schema allowed some attributes or child elements that were not used in the metadata. Example: "collection" name for embedded documents.