- Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
In entity_from_protobuf a key is created and the values are added via
for property_pb in pb.property: value = _get_value_from_property_pb(property_pb) entity[property_pb.name] = valueHowever, property_pb.value.indexed is ignored and entity has the default empty tuple for exclude_from_indexes.
To see this, first save with exclude_from_indexes non-empty and inspect the protobuf values:
>>> from gcloud import datastore >>> from gcloud.datastore.entity import Entity >>> from gcloud.datastore.key import Key >>> >>> datastore.set_default_connection() >>> datastore.set_default_dataset_id('foo') >>> >>> e = Entity(key=Key('Foo', 1), exclude_from_indexes=('foo', 'bar')) >>> e.update({ ... 'foo': 10, ... 'bar': 11, ... 'baz': 12, ... }) >>> e.save() >>> >>> entity_pb, = datastore.get_connection().lookup( ... dataset_id=e.key.dataset_id, ... key_pbs=[e.key.to_protobuf()], ... ) >>> for p in entity_pb.property: ... print p.value.indexed ... True False Falsethen use the key to get (which calls get_entities -> entity_from_protobuf), save the newly created (supposedly identical) Entity. After saving, check the same protobuf values:
>>> e_retrieved = e.key.get() >>> e_retrieved.save() >>> >>> entity_pb, = datastore.get_connection().lookup( ... dataset_id=e_retrieved.key.dataset_id, ... key_pbs=[e_retrieved.key.to_protobuf()], ... ) >>> for p in entity_pb.property: ... print p.value.indexed ... True True TrueMetadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.