API to customize the list of TYPE_MAPPING
See original GitHub issueI 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.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Customization - OpenAPI Generator
Your api.mustache will be used if it exists in your custom template directory ... This will create a new directory out/generators/my-codegen ...
Read more >[JAVA] Better type mapping support · Issue #7589 - GitHub
Description My particular frustration is with the mapping of date types. I'm totally on board with format: date mapping to java.time.
Read more >Fluent API - Configuring and Mapping Properties and Types
This article is designed to demonstrate how to use the fluent API to configure properties. The code first fluent API is most commonly ......
Read more >Mapping Lists with ModelMapper - Baeldung
Learn how to map lists of different element types using Model Mapper. ... generic type mapping, and property mapping to create object list...
Read more >Update mapping API | Elasticsearch Guide [8.5] | Elastic
For new fields, this mapping can include: Field name; Field data type · Mapping parameters. For existing fields, see Change the mapping of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it makes sense to specify a custom converter via Meta if you have a custom SQLAlchemy type that’s used everywhere in your application. There should be a clean/documented way to globally register a new type.
I’m considering making the converter class a class member of the schema rather than
class Meta
option, i.e.This could simplify overriding converter methods and attributes, incl. the type mapping.
Thoughts?