8000 DISCUSSION: Entity still not behaving like a dict · Issue #620 · googleapis/google-cloud-python · GitHub
[go: up one dir, main page]

Skip to content
8000
DISCUSSION: Entity still not behaving like a dict #620
Closed
@elibixby

Description

@elibixby

Since you are (optionally) associating Entities with Keys on instantiation, and since Entity inherits from dict I think it's reasonable to assume that all of the following would work.

ent1 = Entity(key=key1)
ent2 = Entity(key=key2)
assert not dict(ent1) == dict(ent2)

ent = Entity()
assert not 'key' in ent
ent['key'] = Key('Kind', 'id')
datastore.put(ent)

props={'prop1': 'value1', 'prop2':'value2'}
ent = Entity(key=key1, **props)

That said I'm still of the opinion that Entity should not be necessary as a class, using instead datastore.put(key, dict, **options) or, Entity should be completely key agnostic making implementation of the above easier.

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0