Skip to content Skip to sidebar Skip to footer

Sqlalchemy @property Causes 'unknown Field' Error In Marshmallow With Dump_only

I'm using flask-marshmallow (marshmallow=v3.0.0rc1, flask-marshmallow=0.9.0) and flask-sqlalchemy (sqlalchemy=1.2.16, flask-sqlalchemy=2.3.2) I have this model and schema. from mar

Solution 1:

In marshmallow 2, unknown or dump_only fields are ignored from input. Unless the user decides to add his own validation to error on them.

In marshmallow 3, we changed that to offer three possibilities (see docs):

  • RAISE (default)
  • EXCLUDE (like marshmallow 2)
  • INCLUDE (pass data without validation)

There's been discussions about how to deal with dump_only fields and we came to the conclusion that from client perspective, those should be treated just as unknown fields (see https://github.com/marshmallow-code/marshmallow/issues/875).

Bottom line, your PUT payload should not include dump_only fields. Or you could set the EXCLUDE policy to your schema, but I'd favor the former option.

Post a Comment for "Sqlalchemy @property Causes 'unknown Field' Error In Marshmallow With Dump_only"