Skip to content

Commit

Permalink
Make exclude_from_indexes a set, and public API. (#3756)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored Aug 8, 2017
1 parent aaaaf7d commit 1ff7708
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions datastore/google/cloud/datastore/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ class Entity(dict):
def __init__(self, key=None, exclude_from_indexes=()):
super(Entity, self).__init__()
self.key = key
self._exclude_from_indexes = set(_ensure_tuple_or_list(
self.exclude_from_indexes = set(_ensure_tuple_or_list(
'exclude_from_indexes', exclude_from_indexes))
"""Names of fields which are *not* to be indexed for this entity."""
# NOTE: This will be populated when parsing a protobuf in
# google.cloud.datastore.helpers.entity_from_protobuf.
self._meanings = {}
Expand All @@ -148,7 +149,7 @@ def __eq__(self, other):
return False

return (self.key == other.key and
self._exclude_from_indexes == other._exclude_from_indexes and
self.exclude_from_indexes == other.exclude_from_indexes and
self._meanings == other._meanings and
super(Entity, self).__eq__(other))

Expand Down Expand Up @@ -176,15 +177,6 @@ def kind(self):
if self.key:
return self.key.kind

@property
def exclude_from_indexes(self):
"""Names of fields which are *not* to be indexed for this entity.
:rtype: sequence of field names
:returns: The set of fields excluded from indexes.
"""
return frozenset(self._exclude_from_indexes)

def __repr__(self):
if self.key:
return '<Entity%s %s>' % (self.key._flat_path,
Expand Down

0 comments on commit 1ff7708

Please sign in to comment.