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
As far as I can interpret the code correctly, I believe that there is no serialising happening at all for columns provided to a Related field.
From class Related(fields.Field):
def _serialize(self, value, attr, obj):
ret = {prop.key: getattr(value, prop.key, None) for prop in self.related_keys}
return ret if len(ret) > 1 else list(ret.values())[0]
In my case (a REST API built with Flask) this results in Object of type furl is not JSON serializable, as I'm referring to a related model with a sqlalchemy_utils.URLType column, which doesn't return a str but an object from the type furl.
The blind getattr in the code above should be some kind of serialisation instead.
I don't see an easy way of solving this, as of course, the SQLAlchemyAutoSchema refers to the underlying Models to get information about the Related columns, and doesn't know about any Marshmallow Schema related to that other Model.
However, is there a way to force an actual (and correct) serialization of these values?
The text was updated successfully, but these errors were encountered:
As far as I can interpret the code correctly, I believe that there is no serialising happening at all for columns provided to a
Related
field.From
class Related(fields.Field):
In my case (a REST API built with Flask) this results in
Object of type furl is not JSON serializable
, as I'm referring to a related model with asqlalchemy_utils.URLType
column, which doesn't return astr
but an object from the typefurl
.The blind
getattr
in the code above should be some kind of serialisation instead.I don't see an easy way of solving this, as of course, the
SQLAlchemyAutoSchema
refers to the underlyingModel
s to get information about theRelated
columns, and doesn't know about any MarshmallowSchema
related to that otherModel
.However, is there a way to force an actual (and correct) serialization of these values?
The text was updated successfully, but these errors were encountered: