Skip to content

Commit

Permalink
Pass namespace when fetching results.
Browse files Browse the repository at this point in the history
Fixes #170.
  • Loading branch information
tseaver committed Oct 17, 2014
1 parent 83557e3 commit 7820d91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion gcloud/datastore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def fetch(self, limit=None):
end_cursor,
more_results,
skipped_results) = self.dataset().connection().run_query(
query_pb=clone.to_protobuf(), dataset_id=self.dataset().id())
query_pb=clone.to_protobuf(),
dataset_id=self.dataset().id(),
namespace=self._namespace,
)

self._cursor = end_cursor
return [Entity.from_protobuf(entity, dataset=self.dataset())
Expand Down
5 changes: 4 additions & 1 deletion gcloud/datastore/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def test_fetch_default_limit(self):
self.assertEqual(connection._called_with,
{'dataset_id': _DATASET,
'query_pb': query.to_protobuf(),
'namespace': None,
})

def test_fetch_explicit_limit(self):
Expand All @@ -271,6 +272,7 @@ def test_fetch_explicit_limit(self):
_DATASET = 'DATASET'
_KIND = 'KIND'
_ID = 123
_NAMESPACE = 'NAMESPACE'
entity_pb = Entity()
path_element = entity_pb.key.path_element.add()
path_element.kind = _KIND
Expand All @@ -281,7 +283,7 @@ def test_fetch_explicit_limit(self):
connection = _Connection(entity_pb)
connection._cursor = _CURSOR
dataset = _Dataset(_DATASET, connection)
query = self._makeOne(_KIND, dataset)
query = self._makeOne(_KIND, dataset, _NAMESPACE)
limited = query.limit(13)
entities = query.fetch(13)
self.assertEqual(query._cursor, _CURSOR)
Expand All @@ -291,6 +293,7 @@ def test_fetch_explicit_limit(self):
self.assertEqual(connection._called_with,
{'dataset_id': _DATASET,
'query_pb': limited.to_protobuf(),
'namespace': _NAMESPACE,
})

def test_cursor_not_fetched(self):
Expand Down

0 comments on commit 7820d91

Please sign in to comment.