nayan32biswas / mongodb-odm

MongoDB-ODM, NOSQL databases in Python, designed for simplicity, compatibility, and robustness.
https://mongodb-odm.readthedocs.io
MIT License
17 stars 1 forks source link

Is there only one Level of inheritance? #33

Open Magnati opened 1 week ago

Magnati commented 1 week ago

The docs state that the inheriting class of a Document must declare

    class ODMConfig(Document.ODMConfig):
        allow_inheritance = False

However, that means there is no way of inheriting from an inheriting class like the following, correct?


class Ship(Document):
    name: str

    class ODMConfig(Document.ODMConfig):
        allow_inheritance = True

class SpaceShip(Ship):
    warp_factor: float

    class ODMConfig(Document.ODMConfig):
        allow_inheritance = True

class Voyager(SpaceShip):
    seven_on_board: bool

    class ODMConfig(Document.ODMConfig):
        allow_inheritance = False
nayan32biswas commented 1 week ago

Hi @Magnati, currently we support one level of inheritance.

Also, we have noticed all of your other issues. Soon we will fix those issues.

Thanks for raising the issue.

Magnati commented 1 week ago

Okay. I opened a PR for a docs update since that should be mentioned on the Advanced page, https://github.com/nayan32biswas/mongodb-odm/pull/34. I work on projects with maybe 7 levels of inheritance?

So that would be also a major wish for a future Feature.

nayan32biswas commented 23 hours ago

Your PR #34 got merged. Thank you for your support.

Also thank you for your suggestion. We will come up with a solution to handle multi-label inheritance. It would be highly appreciated if you come up with a draft solution on multi-label inheritance.