BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.9k stars 201 forks source link

[BUG] `original_field` is not supported by pydantic, makes typecheckers give a type error and causes a warning at runtime #950

Open ldorigo opened 3 weeks ago

ldorigo commented 3 weeks ago

Not much to add - e.g.:

class Foo(Document):
   bar: Link[Bar]

class Bar(Document):
  foos: list[BackLink[Foo]] = Field(original_field="bar")
IterableTrucks commented 2 weeks ago

original_field should be declared in the json_schema_extra dictionary in pydantic v2 models. The documentation has not been updated. You can refer to this issue https://github.com/BeanieODM/beanie/issues/885#issuecomment-1992331172