marshmallow-sqlalchemy icon indicating copy to clipboard operation
marshmallow-sqlalchemy copied to clipboard

Using `Related(column=...)` with non-standard column types

Open AbdealiLoKo opened this issue 2 years ago • 0 comments

I have a model which uses EnumType from sqlalchemy called category. When I try to dump some information in my schema with Related(column='category') It throws an error that Enum cannot be serialized to JSON

Is there a way for me to let ma-sqla know that this field should be dumped using a field I have created called EnumField which handles the serialization and deserialization logic ?

I guess Related is currently assuming it can take the value from the DB directly. So, maybe we need a Related(column='category', column_field=EnumField) or something which is used to serialize/deserialize the value

AbdealiLoKo avatar Jan 13 '23 09:01 AbdealiLoKo