You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although marshmallow is not just for sqlalchemy, I think a reasonable standard for completeness is: "It can be used to serialize the basic types of sqlalchemy." One thing that's kinda inconvenient right now is enums. My current issue is with sqlalchemy columns constructed from pep 435 enums, although it applies equally to the enums themselves.
so I propose adding a new kind* of field, Enum, which would allow some syntax like
fields.Enum(int)
fields.Enum(fields.String)
fields.Enum(MyEnumClass)
it wouldn't really have to do much except fetch via attrname.name or attrname.value** instead of just attrname by default, and, if the enum class is available, autogenerate a OneOf validator expr. It should also appear from the outside (e.g. to consumers like apispec) to be of whatever type the actual value is (i.e. the type of the name or the type of the value, depending).
I've never made a custom field before & don't really know how it's done so it would be awesome if somebody more skilled could do this for me, but I have a feeling I'll have to submit my own PR after figuring it all out <curses under breath>
*Haskell nerds: I use the term 'kind' advisedly
**Perhaps by-name & by-value would be 2 separate kinds
The text was updated successfully, but these errors were encountered:
Although marshmallow is not just for sqlalchemy, I think a reasonable standard for completeness is: "It can be used to serialize the basic types of sqlalchemy." One thing that's kinda inconvenient right now is enums. My current issue is with sqlalchemy columns constructed from pep 435 enums, although it applies equally to the enums themselves.
so I propose adding a new kind* of field,
Enum
, which would allow some syntax likefields.Enum(int)
fields.Enum(fields.String)
fields.Enum(MyEnumClass)
it wouldn't really have to do much except fetch via attrname.name or attrname.value** instead of just attrname by default, and, if the enum class is available, autogenerate a OneOf validator expr. It should also appear from the outside (e.g. to consumers like apispec) to be of whatever type the actual value is (i.e. the type of the name or the type of the value, depending).
I've never made a custom field before & don't really know how it's done so it would be awesome if somebody more skilled could do this for me, but I have a feeling I'll have to submit my own PR after figuring it all out <curses under breath>
*Haskell nerds: I use the term 'kind' advisedly
**Perhaps by-name & by-value would be 2 separate kinds
The text was updated successfully, but these errors were encountered: