10000 Drop munging of 's~' prefix onto keys. · googleapis/google-cloud-python@538084d · GitHub
[go: up one dir, main page]

Skip to content

Commit 538084d

Browse files
committed
Drop munging of 's~' prefix onto keys.
Fixes #121. Note: may conflict with PR #257 and #258.
1 parent 906700b commit 538084d

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

gcloud/datastore/key.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,8 @@ def to_protobuf(self):
9595
# but we shouldn't throw a cryptic error if one isn't provided
9696
# in the initializer.
9797
if self.dataset():
98-
# Apparently 's~' is a prefix for High-Replication and is necessary
99-
# here. Another valid preflix is 'e~' indicating EU datacenters.
10098
dataset_id = self.dataset().id()
10199
if dataset_id:
102-
if dataset_id[:2] not in ['s~', 'e~']:
103-
dataset_id = 's~' + dataset_id
104-
105100
key.partition_id.dataset_id = dataset_id
106101

107102
if self._namespace:

gcloud/datastore/test_connection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def test_lookup_single_key_empty_response(self):
406406
self.assertEqual(cw['method'], 'POST')
407407
self.assertEqual(cw['headers'],
408408
{'Content-Type': 'application/x-protobuf',
409-
'Content-Length': '26',
409+
'Content-Length': '24',
410410
'User-Agent': conn.USER_AGENT,
411411
})
412412
rq_class = datastore_pb.LookupRequest
@@ -445,7 +445,7 @@ def test_lookup_single_key_nonempty_response(self):
445445
self.assertEqual(cw['method'], 'POST')
446446
self.assertEqual(cw['headers'],
447447
{'Content-Type': 'application/x-protobuf',
448-
'Content-Length': '26',
448+
'Content-Length': '24',
449449
'User-Agent': conn.USER_AGENT,
450450
})
451451
rq_class = datastore_pb.LookupRequest
@@ -481,7 +481,7 @@ def test_lookup_multiple_keys_empty_response(self):
481481
self.assertEqual(cw['method'], 'POST')
482482
self.assertEqual(cw['headers'],
483483
{'Content-Type': 'application/x-protobuf',
484-
'Content-Length': '52',
484+
'Content-Length': '48',
485485
'User-Agent': conn.USER_AGENT,
486486
})
487487
rq_class = datastore_pb.LookupRequest
@@ -524,7 +524,7 @@ def test_commit_wo_transaction(self):
524524
self.assertEqual(cw['method'], 'POST')
525525
self.assertEqual(cw['headers'],
526526
{'Content-Type': 'application/x-protobuf',
527-
'Content-Length': '47',
527+
'Content-Length': '45',
528528
'User-Agent': conn.USER_AGENT,
529529
})
530530
rq_class = datastore_pb.CommitRequest
@@ -570,7 +570,7 @@ def id(self):
570570
self.assertEqual(cw['method'], 'POST')
571571
self.assertEqual(cw['headers'],
572572
{'Content-Type': 'application/x-protobuf',
573-
'Content-Length': '53',
573+
'Content-Length': '51',
574574
'User-Agent': conn.USER_AGENT,
575575
})
576576
rq_class = datastore_pb.CommitRequest
@@ -605,7 +605,7 @@ def test_save_entity_wo_transaction_w_upsert(self):
605605
self.assertEqual(cw['method'], 'POST')
606606
self.assertEqual(cw['headers'],
607607
{'Content-Type': 'application/x-protobuf',
608-
'Content-Length': '47',
608+
'Content-Length': '45',
609609
'User-Agent': conn.USER_AGENT,
610610
})
611611
rq_class = datastore_pb.CommitRequest
@@ -656,7 +656,7 @@ def test_save_entity_wo_transaction_w_auto_id(self):
656656
self.assertEqual(cw['method'], 'POST')
657657
self.assertEqual(cw['headers'],
658658
{'Content-Type': 'application/x-protobuf',
659-
'Content-Length': '44',
659+
'Content-Length': '42',
660660
'User-Agent': conn.USER_AGENT,
661661
})
662662
rq_class = datastore_pb.CommitRequest
@@ -751,7 +751,7 @@ def test_delete_entities_wo_transaction(self):
751751
self.assertEqual(cw['method'], 'POST')
752752
self.assertEqual(cw['headers'],
753753
{'Content-Type': 'application/x-protobuf',
754-
'Content-Length': '30',
754+
'Content-Length': '28',
755755
'User-Agent': conn.USER_AGENT,
756756
})
757757
rq_class = datastore_pb.CommitRequest
@@ -816,7 +816,7 @@ def test_delete_entity_wo_transaction(self):
816816
self.assertEqual(cw['method'], 'POST')
817817
self.assertEqual(cw['headers'],
818818
{'Content-Type': 'application/x-protobuf',
819-
'Content-Length': '30',
819+
'Content-Length': '28',
820820
'User-Agent': conn.USER_AGENT,
821821
})
822822
rq_class = datastore_pb.CommitRequest

gcloud/datastore/test_key.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,12 @@ def test_to_protobuf_w_explicit_dataset_empty_id(self):
133133
pb = key.to_protobuf()
134134
self.assertEqual(pb.partition_id.dataset_id, '')
135135

136-
def test_to_protobuf_w_explicit_dataset_no_prefix(self):
136+
def test_to_protobuf_w_explicit_dataset(self):
137137
from gcloud.datastore.dataset import Dataset
138138
_DATASET = 'DATASET'
139139
dataset = Dataset(_DATASET)
140140
key = self._makeOne(dataset)
141141
pb = key.to_protobuf()
142-
self.assertEqual(pb.partition_id.dataset_id, 's~%s' % _DATASET)
143-
144-
def test_to_protobuf_w_explicit_dataset_w_s_prefix(self):
145-
from gcloud.datastore.dataset import Dataset
146-
_DATASET = 's~DATASET'
147-
dataset = Dataset(_DATASET)
148-
key = self._makeOne(dataset)
149-
pb = key.to_protobuf()
150-
self.assertEqual(pb.partition_id.dataset_id, _DATASET)
151-
152-
def test_to_protobuf_w_explicit_dataset_w_e_prefix(self):
153-
from gcloud.datastore.dataset import Dataset
154-
_DATASET = 'e~DATASET'
155-
dataset = Dataset(_DATASET)
156-
key = self._makeOne(dataset)
157-
pb = key.to_protobuf()
158142
self.assertEqual(pb.partition_id.dataset_id, _DATASET)
159143

160144
def test_to_protobuf_w_explicit_namespace(self):

0 commit comments

Comments
 (0)
0