Skip to content

Commit 6eef6f7

Browse files
committed
Renaming namespace->namespace_id on PartitionId.
1 parent 94526a1 commit 6eef6f7

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

gcloud/datastore/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def run_query(self, project, query_pb, namespace=None,
264264
_set_read_options(request, eventual, transaction_id)
265265

266266
if namespace:
267-
request.partition_id.namespace = namespace
267+
request.partition_id.namespace_id = namespace
268268

269269
request.query.CopyFrom(query_pb)
270270
response = self._rpc(project, 'runQuery', request,

gcloud/datastore/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ def key_from_protobuf(pb):
271271
if _has_field(pb.partition_id, 'project_id'):
272272
project = pb.partition_id.project_id
273273
namespace = None
274-
if pb.partition_id.HasField('namespace'):
275-
namespace = pb.partition_id.namespace
274+
if _has_field(pb.partition_id, 'namespace_id'):
275+
namespace = pb.partition_id.namespace_id
276276

277277
return Key(*path_args, namespace=namespace, project=project)
278278

gcloud/datastore/key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def to_protobuf(self):
243243
key.partition_id.project_id = self.project
244244

245245
if self.namespace:
246-
key.partition_id.namespace = self.namespace
246+
key.partition_id.namespace_id = self.namespace
247247

248248
for item in self.path:
249249
element = key.path_element.add()

gcloud/datastore/test_connection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def test_run_query_w_eventual_no_transaction(self):
508508
rq_class = datastore_pb2.RunQueryRequest
509509
request = rq_class()
510510
request.ParseFromString(cw['body'])
511-
self.assertEqual(request.partition_id.namespace, '')
511+
self.assertEqual(request.partition_id.namespace_id, '')
512512
self.assertEqual(request.query, q_pb)
513513
self.assertEqual(request.read_options.read_consistency,
514514
datastore_pb2.ReadOptions.EVENTUAL)
@@ -549,7 +549,7 @@ def test_run_query_wo_eventual_w_transaction(self):
549549
rq_class = datastore_pb2.RunQueryRequest
550550
request = rq_class()
551551
request.ParseFromString(cw['body'])
552-
self.assertEqual(request.partition_id.namespace, '')
552+
self.assertEqual(request.partition_id.namespace_id, '')
553553
self.assertEqual(request.query, q_pb)
554554
self.assertEqual(request.read_options.read_consistency,
555555
datastore_pb2.ReadOptions.DEFAULT)
@@ -606,7 +606,7 @@ def test_run_query_wo_namespace_empty_result(self):
606606
rq_class = datastore_pb2.RunQueryRequest
607607
request = rq_class()
608608
request.ParseFromString(cw['body'])
609-
self.assertEqual(request.partition_id.namespace, '')
609+
self.assertEqual(request.partition_id.namespace_id, '')
610610
self.assertEqual(request.query, q_pb)
611611

612612
def test_run_query_w_namespace_nonempty_result(self):
@@ -638,7 +638,7 @@ def test_run_query_w_namespace_nonempty_result(self):
638638
rq_class = datastore_pb2.RunQueryRequest
639639
request = rq_class()
640640
request.ParseFromString(cw['body'])
641-
self.assertEqual(request.partition_id.namespace, 'NS')
641+
self.assertEqual(request.partition_id.namespace_id, 'NS')
642642
self.assertEqual(request.query, q_pb)
643643

644644
def test_begin_transaction(self):
@@ -902,8 +902,8 @@ def request(self, **kw):
902902
def _compare_key_pb_after_request(test, key_before, key_after):
903903
from gcloud._helpers import _has_field
904904
test.assertFalse(_has_field(key_after.partition_id, 'project_id'))
905-
test.assertEqual(key_before.partition_id.namespace,
906-
key_after.partition_id.namespace)
905+
test.assertEqual(key_before.partition_id.namespace_id,
906+
key_after.partition_id.namespace_id)
907907
test.assertEqual(len(key_before.path_element),
908908
len(key_after.path_element))
909909
for elt1, elt2 in zip(key_before.path_element, key_after.path_element):

gcloud/datastore/test_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def _makePB(self, project=None, namespace=None, path=()):
357357
if project is not None:
358358
pb.partition_id.project_id = project
359359
if namespace is not None:
360-
pb.partition_id.namespace = namespace
360+
pb.partition_id.namespace_id = namespace
361361
for elem in path:
362362
added = pb.path_element.add()
363363
added.kind = elem['kind']

gcloud/datastore/test_key.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def test_completed_key_on_complete(self):
333333
self.assertRaises(ValueError, key.completed_key, 5678)
334334

335335
def test_to_protobuf_defaults(self):
336+
from gcloud._helpers import _has_field
336337
from gcloud.datastore._generated import entity_pb2
337338
_KIND = 'KIND'
338339
key = self._makeOne(_KIND, project=self._DEFAULT_PROJECT)
@@ -341,8 +342,8 @@ def test_to_protobuf_defaults(self):
341342

342343
# Check partition ID.
343344
self.assertEqual(pb.partition_id.project_id, self._DEFAULT_PROJECT)
344-
self.assertEqual(pb.partition_id.namespace, '')
345-
self.assertFalse(pb.partition_id.HasField('namespace'))
345+
self.assertEqual(pb.partition_id.namespace_id, '')
346+
self.assertFalse(_has_field(pb.partition_id, 'namespace_id'))
346347

347348
# Check the element PB matches the partial key and kind.
348349
elem, = list(pb.path_element)
@@ -363,7 +364,7 @@ def test_to_protobuf_w_explicit_namespace(self):
363364
key = self._makeOne('KIND', namespace=_NAMESPACE,
364365
project=self._DEFAULT_PROJECT)
365366
pb = key.to_protobuf()
366-
self.assertEqual(pb.partition_id.namespace, _NAMESPACE)
367+
self.assertEqual(pb.partition_id.namespace_id, _NAMESPACE)
367368

368369
def test_to_protobuf_w_explicit_path(self):
369370
_PARENT = 'PARENT'

0 commit comments

Comments
 (0)