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] = value
However, 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
False
then 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
True
In
entity_from_protobufa key is created and the values are added viaHowever,
property_pb.value.indexedis ignored andentityhas the default empty tuple forexclude_from_indexes.To see this, first save with
exclude_from_indexesnon-empty and inspect the protobuf values:then use the key to
get(which callsget_entities->entity_from_protobuf), save the newly created (supposedly identical)Entity. After saving, check the same protobuf values: