Skip to content

ConstantField produces error when converting to marshmallow schema #377

@GorillaGroddUK

Description

@GorillaGroddUK

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'

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