marshmallow-code / marshmallow-code/marshmallow-sqlalchemy
API to customize the list of TYPE_MAPPING
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 580
- Forks
- 101
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 3
Description
I use sqlalchemy_utils which provide ChoiceType field (and many others).
I'm able to create a new Marshmallow field (Field) to handle this new field with proper `_serialize/_deserialize` functions but instead to override the attributes one by one in each schema I defined I want to update the list type_mapping in ModelConverter.
I didn't find how to access it properly, ModelConverter accepts `schema_cls` attribute at init
https://github.com/marshmallow-code/marshmallow-sqlalchemy/blob/dev/marshmallow_sqlalchemy/convert.py#L76
but I'm not able to figure out how to use it properly with all these meta classes ;)
So for now I rely on a monkey patch:
```
ModelConverter.SQLA_TYPE_MAPPING.update({
ChoiceType: ChoiceTypeSchema
})
```
PS: I use flask-marshmallow in my app.
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 in marshmallow_sqlalchemy/convert.py at ModelConverter and SQLA_TYPE_MAPPING, then review the issue discussion for the intended customization boundary. Done means users can register a custom SQLAlchemy field mapping through a supported API instead of monkey-patching the class mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100