Skip to content

Commit bfffdbf

Browse files
committed
Pass namespace when fetching results.
Fixes #170.
1 parent c120f65 commit bfffdbf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gcloud/datastore/query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ def fetch(self, limit=None):
329329
clone = self.limit(limit)
330330

331331
query_results = self.dataset().connection().run_query(
332-
query_pb=clone.to_protobuf(), dataset_id=self.dataset().id())
332+
query_pb=clone.to_protobuf(),
333+
dataset_id=self.dataset().id(),
334+
namespace=self._namespace,
335+
)
333336
entity_pbs, end_cursor = query_results[:2]
334337

335338
self._cursor = end_cursor

gcloud/datastore/test_query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def test_fetch_default_limit(self):
262262
expected_called_with = {
263263
'dataset_id': _DATASET,
264264
'query_pb': query.to_protobuf(),
265+
'namespace': None,
265266
}
266267
self.assertEqual(connection._called_with, expected_called_with)
267268

@@ -271,6 +272,7 @@ def test_fetch_explicit_limit(self):
271272
_DATASET = 'DATASET'
272273
_KIND = 'KIND'
273274
_ID = 123
275+
_NAMESPACE = 'NAMESPACE'
274276
entity_pb = Entity()
275277
path_element = entity_pb.key.path_element.add()
276278
path_element.kind = _KIND
@@ -281,7 +283,7 @@ def test_fetch_explicit_limit(self):
281283
connection = _Connection(entity_pb)
282284
connection._cursor = _CURSOR
283285
dataset = _Dataset(_DATASET, connection)
284-
query = self._makeOne(_KIND, dataset)
286+
query = self._makeOne(_KIND, dataset, _NAMESPACE)
285287
limited = query.limit(13)
286288
entities = query.fetch(13)
287289
self.assertEqual(query._cursor, _CURSOR)
@@ -291,6 +293,7 @@ def test_fetch_explicit_limit(self):
291293
expected_called_with = {
292294
'dataset_id': _DATASET,
293295
'query_pb': limited.to_protobuf(),
296+
'namespace': _NAMESPACE,
294297
}
295298
self.assertEqual(connection._called_with, expected_called_with)
296299

0 commit comments

Comments
 (0)