-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.
Description
In Key.id(), the check
def id(self, id_to_set=None):
...
if id_to_set:
clone = self._clone()also ignores False-y objects other than None.
This means it ignores the integer 0, which would seem to be a valid ID. However, the backend actually rejects this, so maybe this bug only requires fixing the docstring?
>>> from gcloud import datastore
>>> cnxn = datastore.get_connection()
>>> import os
>>> dataset = cnxn.dataset(os.getenv('GCLOUD_TESTS_DATASET_ID'))
>>> entity = dataset.entity('foo')
>>> entity.key()._path
[{'kind': 'foo'}]
>>> entity.key()._path[0]['id'] = 0
>>> entity
<Entity[{'kind': 'foo', 'id': 0}] {}>
>>> entity['bar'] = u'baz'
>>> entity.save()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "gcloud/datastore/entity.py", line 246, in save
exclude_from_indexes=self.exclude_from_indexes())
File "gcloud/datastore/connection.py", line 477, in save_entity
result = self.commit(dataset_id, mutation)
File "gcloud/datastore/connection.py", line 377, in commit
datastore_pb.CommitResponse)
File "gcloud/datastore/connection.py", line 95, in _rpc
data=request_pb.SerializeToString())
File "gcloud/datastore/connection.py", line 73, in _request
raise Exception('Request failed. Error was: %s' % content)
Exception: Request failed. Error was: Key path id is invalid. Must not be zero./cc @pcostell
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.