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

Deprecate COLLECTION_PER_CLASS inheritance #2742

Open
GromNaN opened this issue Mar 4, 2025 · 1 comment
Open

Deprecate COLLECTION_PER_CLASS inheritance #2742

GromNaN opened this issue Mar 4, 2025 · 1 comment

Comments

@GromNaN
Copy link
Member

GromNaN commented Mar 4, 2025

Feature Request

Q A
New Feature no
RFC yes
BC Break yes

Summary

The the COLLECTION_PER_CLASS inheritance means there is 1 collection per Document class. Which is not different from how all the Document classes works.

Getting the example from #2726

#[ODM\InheritanceType('COLLECTION_PER_CLASS')]
#[ODM\DiscriminatorMap([3 => Tag::class, 4 => Category::class])]
class Section {}

class Tag extends Section {}
class Category extends Section {}

If you run a query on the Section repository, the section collection is queried. There is no way to get a Tag or Category object in this way.

If you run a query on the Tag repository, the tag collection is queried. There is no way to get a Category object in this way. The discriminator field is not necessary.

This feature has an issue as we cannot guarantee that 2 documents doesn't share the same _id, as they are in distinct collections. #2725 (comment)

This feature has almost no documentation: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.9/reference/inheritance-mapping.html#collection-per-class-inheritance

@GromNaN
Copy link
Member Author

GromNaN commented Mar 5, 2025

I'm thinking about it now, maybe the use case is for polymorphic relationships.

Edit: that's not confirmed by the introduction commit 7613b91, there is no relationships in the examples and tests.

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

No branches or pull requests

1 participant