marshmallow-code / marshmallow-code/marshmallow-sqlalchemy
Using `Related(column=...)` with non-standard column types
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 580
- Forks
- 101
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 3
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the error with SQLAlchemy's EnumType, a model column named category, and Related(column='category') using the custom EnumField described in the issue. Trace how Related serializes the database value; done means the requested field can control serialization and deserialization without the Enum JSON error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100