Skip to content

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

Open
@Quidge

Description

@Quidge

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions