Scille / umongo

sync/async MongoDB ODM, yes.
MIT License
448 stars 63 forks source link

ConstantField produces error when converting to marshmallow schema #377

Open GoriilaGrodd opened 2 years ago

GoriilaGrodd commented 2 years ago

as_marshmallow_schema returned the following message for the ConstantField attribute:

@instance.register
class Dog(Document):
    breed = fields.ConstantField("Mongrel")

DogMaSchema = Dog.schema.as_marshmallow_schema()

Traceback (most recent call last):
  File "...\AppData\Local\Programs\Python\Python38\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 5, in <module>
  File "...\.venv\lib\site-packages\umongo\abstract.py", line 66, in as_marshmallow_schema
    nmspc = {
  File "...\.venv\lib\site-packages\umongo\abstract.py", line 67, in <dictcomp>
    name: field.as_marshmallow_field()
  File "...\.venv\lib\site-packages\umongo\abstract.py", line 209, in as_marshmallow_field
    m_field = m_class(**field_kwargs, metadata=self.metadata)
TypeError: __init__() missing 1 required positional argument: 'constant'