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
Indexes not created when embedding a document using mixed document types #1135
Comments
@bicatu if you want indexes for embedded documents to be created you have to provide |
Hi @malarzm it is clear even though I do not agree per se. The field type tell it what class to use for the embedded document and in the class I do have the indexes. Hence in my opinion there is a way of achieving the same functionality as when we have when we statically map the document. May I suggest that if this is not a feature request at least the documentation on the indexes page is updated to make this limitation clear. |
@bicatu what field type are you referring to?
|
When I am persisting the document (with its embedded sub-document) I have the entity and the discriminatorField which contains the class name of that embedded document. From that name I have the definition, hence the index annotation. Is this clear? |
As far as I am concerned ODM is not checking in database what embedded documents are used in main documents, only metadata is used for that.
Can you please paste a link to that part of docs? |
Hi http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/indexes.html is the one that mentions at the section "Embedded Indexes" about the creation of the indexes for embedded documents. And http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/embedded-mapping.html#mixing-document-types for the embedded documents. So there is no mention that "in order to create the indexes you have to specify the targetDocument or the discrimitatorMap on the Document" |
Indeed we should amend the documentation (or would you mind making a PR?). Thank you for the report! |
I can make the PR. Is there any reference on the proper procedure to do so - update the documentation ? |
I don't think we have a procedure for that - you just open a PR with needed changes referencing this issue, we review that, maybe ask for amendments and merge afterwards :) |
I created a pull request. |
See #1143. |
#1143 has been merged. |
According to the user manual when I specify the indexes on a embedded document it will be created when persisting the main document.
It is not happening when the embedded document type varies.
To reproduce
Main Document Entity
First embedded type
test code
When using find the document and the embedded data has been saved but the getIndexes does not show anything other than the _id.
If I update the annotation to mention targetDocument the index gets created normally.
The text was updated successfully, but these errors were encountered: