Skip to content

Deprecate COLLECTION_PER_CLASS inheritance #2742

Open
@GromNaN

Description

@GromNaN

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions