Skip to content

Support mix of concrete inheritance and pydantic mixin #877

Description

@iron3oxide

Is your feature request related to a problem? Please describe.
When defining an ormar.Model and inheriting from both an abstract ormar.Model and a mixin (pydantic in my case), two problems arise:

  1. The resulting model is abstract by default, see Model inheriting from abstract models is abstract by default #876 (couldn't edit the issue sufficiently so I decided to reference it here)
  2. Two database tables are generated (e.g. "nation" and "nations"), both with the mixin fields missing.

Describe the solution you'd like
Modifications to the inheritance design so that the resulting model is working and non-abstract.

Describe alternatives you've considered
Using abstract ormar.Model instead of pydantic BaseModel for the Create, Read and Update classes (if I understood everything correctly, I have to use ormar Fields anyway and the validation should still work). I don't know how much parsing/validation overhead I am adding with this though.

EDIT: just tried it and it does not work since an abstract ormar.Model can of course not be instantiated and thus not used for validation 🤦‍♂️

UPDATE: I must have made some kind of mistake; I can only recreate one of my findings on second try: the mixin fields don't appear in the final tables. I've updated the issue accordingly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions