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 19, 2014
1 parent c120f65 commit bfffdbf
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 @@ -329,7 +329,10 @@ def fetch(self, limit=None):
clone = self.limit(limit)

query_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,
)
entity_pbs, end_cursor = query_results[:2]

self._cursor = end_cursor
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 @@ -262,6 +262,7 @@ def test_fetch_default_limit(self):
expected_called_with = {
'dataset_id': _DATASET,
'query_pb': query.to_protobuf(),
'namespace': None,
}
self.assertEqual(connection._called_with, expected_called_with)

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):
expected_called_with = {
'dataset_id': _DATASET,
'query_pb': limited.to_protobuf(),
'namespace': _NAMESPACE,
}
self.assertEqual(connection._called_with, expected_called_with)

Expand Down

0 comments on commit bfffdbf

Please sign in to comment.