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
In my application, I have an API endpoint like so:
/api/activities/
In my database, I have several different types of Activity models, all inheriting from a common class. I made a schema like so:
class ActivitySchema(ModelSchema):
class Meta:
model = models.Activity
And then have flask-restful handle the api endpoint itself, querying the database and passing the objects to marshmallow-alchemy.
However, marshmallow-sqlalchemy serializes the objects as if they were all of the base Activity type. It would be nice if there was some support like this:
class ActivitySchema(ModelSchema):
class Meta:
model = models.Activity
generate_polymorphic_schemas = True
Which would use sqlalchemy's inspection to view all polymorpic subclasses of Meta.model, store them on ActivitySchema, and then when serializing/deserializing use the appropriate class.
Thoughts?
If this is a desirable feature, I can try to make a PR implementing such functionality.
The text was updated successfully, but these errors were encountered:
In my application, I have an API endpoint like so:
/api/activities/
In my database, I have several different types of Activity models, all inheriting from a common class. I made a schema like so:
And then have flask-restful handle the api endpoint itself, querying the database and passing the objects to marshmallow-alchemy.
However, marshmallow-sqlalchemy serializes the objects as if they were all of the base Activity type. It would be nice if there was some support like this:
Which would use sqlalchemy's inspection to view all polymorpic subclasses of
Meta.model
, store them onActivitySchema
, and then when serializing/deserializing use the appropriate class.Thoughts?
If this is a desirable feature, I can try to make a PR implementing such functionality.
The text was updated successfully, but these errors were encountered: