Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only using 'id' OR 'name' from pb path in datastore.Entity.save. #291

Merged
merged 1 commit into from
Oct 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions gcloud/datastore/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,12 @@ def save(self):
transaction.add_auto_id_entity(self)

if isinstance(key_pb, datastore_pb.Key):
path = [
{'kind': element.kind, 'id': element.id, 'name': element.name}
for element in key_pb.path_element]
path = []
for element in key_pb.path_element:
key_part = {}
for descriptor, value in element._fields.items():
key_part[descriptor.name] = value
path.append(key_part)
# Update the path (which may have been altered).
self._key = key.path(path)

Expand Down
2 changes: 1 addition & 1 deletion gcloud/datastore/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_save_w_returned_key(self):
self.assertEqual(entity['foo'], 'Foo')
self.assertEqual(connection._saved,
(_DATASET_ID, 'KEY', {'foo': 'Foo'}))
self.assertEqual(key._path, [{'kind': _KIND, 'id': _ID, 'name': ''}])
self.assertEqual(key._path, [{'kind': _KIND, 'id': _ID}])

def test_delete_no_key(self):
from gcloud.datastore.entity import NoKey
Expand Down