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
{{ message }}
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
I found an issue where reusing a Schema instance causes old data to be included in future dumps. This example shows it happening for the included section, but I expect it is also an issue for the meta section too.
frommarshmallow_jsonapiimportSchema, fieldsclassAddressSchema(Schema):
id=fields.Str()
name=fields.Str()
classMeta:
type_="addresses"classUserSchema(Schema):
id=fields.Str()
name=fields.Str()
address=fields.Relationship(type_="addresses", schema=AddressSchema())
classMeta:
type_="addresses"address=dict(id="addr-uuid", name="My Address Name")
user=dict(id="user-uuid", name="User Name", address=address)
address_other=dict(id="another-addr-uuid", name="Not your address")
user_other=dict(id="another-user-uuid", name="Stranger Danger", address=address_other)
user_schema=UserSchema(include_data=('address',))
user_dump=user_schema.dumps(user).data# This will include the address from the first dump in erroruser_other_dump=user_schema.dumps(user_other).data# This fails because `address` is still in the user_schema.included_data member dictionaryassertaddress["id"] notinuser_other_dump
The text was updated successfully, but these errors were encountered:
I use a base schema class for all my schemas that includes this pre_dump (and some other stuff) so its not so tedious, but it would be nice to see a real fix for this.
I found an issue where reusing a Schema instance causes old data to be included in future dumps. This example shows it happening for the
included
section, but I expect it is also an issue for themeta
section too.The text was updated successfully, but these errors were encountered: