Skip to content

Datastore: empty lists are not reflected in 'client.put' #6284

Description

@crwilcox

Related to #3767

Currently, Sending an empty array results in the field not being set.

fromgoogle.cloudimportdatastoreds=datastore.Client()
key=ds.key('Test')
entity=datastore.Entity(key=key)
entity['children'] = []
ds.put(entity)
print(entity)
value=ds.get(entity.key)
print(value)
key=ds.key('Test')
entity=datastore.Entity(key=key)
entity['children'] = ['A']
ds.put(entity)
print(entity)
value=ds.get(entity.key)
print(value)

Output:

<Entity('Test', 5707090131681280) {'children': []}>
<Entity('Test', 5707090131681280) {}>
<Entity('Test', 5682274280407040) {'children': ['A']}>
<Entity('Test', 5682274280407040) {'children': ['A']}>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions