dynamorm icon indicating copy to clipboard operation
dynamorm copied to clipboard

How can I persist a schemaless dict where some of the entry values are None?

Open Quidge opened this issue 4 years ago • 0 comments

I need dynamorm not to strip out Nones in some cases. The data isn't structured, so I can't map it to a marshmallow schema and rely on missing=None.

class Model(DynaModel):
    class Table:
        name = 'table'
        hash_key = "key"
		
	class Schema:
		key = marshmallow.fields.Integer()
		some_formless_data = marshmallow.fields.Dict()

m = Model(key=1, some_formless_data={'foo': 'bar', 'noneval': None})
m.save()

same = Model.get(key=1)
same.some_formless_data
>> {'foo': 'bar'}

It's not saving the entries whose values are None. This seems like a common issue -- how do I persist and save a value as a None?

Quidge avatar Aug 06 '20 15:08 Quidge