File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed
Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -91,18 +91,9 @@ def to_protobuf(self):
9191 """
9292 key = datastore_pb .Key ()
9393
94- # Technically a dataset is required to do anything with the key,
95- # but we shouldn't throw a cryptic error if one isn't provided
96- # in the initializer.
97- 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.
100- dataset_id = self .dataset ().id ()
101- if dataset_id :
102- if dataset_id [:2 ] not in ['s~' , 'e~' ]:
103- dataset_id = 's~' + dataset_id
104-
105- key .partition_id .dataset_id = dataset_id
94+ # Don't copy the dataset ID to the protobuf: the backend
95+ # already knows the dataset we are working with, and sets
96+ # it on returned keys.
10697
10798 if self ._namespace :
10899 key .partition_id .namespace = self ._namespace
Original file line number Diff line number Diff line change @@ -139,23 +139,23 @@ def test_to_protobuf_w_explicit_dataset_no_prefix(self):
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 )
142+ self .assertEqual (pb .partition_id .dataset_id , '' )
143143
144144 def test_to_protobuf_w_explicit_dataset_w_s_prefix (self ):
145145 from gcloud .datastore .dataset import Dataset
146146 _DATASET = 's~DATASET'
147147 dataset = Dataset (_DATASET )
148148 key = self ._makeOne (dataset )
149149 pb = key .to_protobuf ()
150- self .assertEqual (pb .partition_id .dataset_id , _DATASET )
150+ self .assertEqual (pb .partition_id .dataset_id , '' )
151151
152152 def test_to_protobuf_w_explicit_dataset_w_e_prefix (self ):
153153 from gcloud .datastore .dataset import Dataset
154154 _DATASET = 'e~DATASET'
155155 dataset = Dataset (_DATASET )
156156 key = self ._makeOne (dataset )
157157 pb = key .to_protobuf ()
158- self .assertEqual (pb .partition_id .dataset_id , _DATASET )
158+ self .assertEqual (pb .partition_id .dataset_id , '' )
159159
160160 def test_to_protobuf_w_explicit_namespace (self ):
161161 _NAMESPACE = 'NAMESPACE'
You can’t perform that action at this time.
0 commit comments