Skip to content

Commit

Permalink
Restrict requested fields in 'Dataset.exists' API request.
Browse files Browse the repository at this point in the history
Addresses:
#1018 (comment)
  • Loading branch information
tseaver committed Jul 28, 2015
1 parent ff626b7 commit 43bafba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def exists(self, client=None):
client = self._require_client(client)

try:
client.connection.api_request(method='GET', path=self.path)
client.connection.api_request(method='GET', path=self.path,
query_params={'fields': 'id'})
except NotFound:
return False
else:
Expand Down
2 changes: 2 additions & 0 deletions gcloud/bigquery/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def test_exists_miss_w_bound_client(self):
req = conn._requested[0]
self.assertEqual(req['method'], 'GET')
self.assertEqual(req['path'], '/%s' % PATH)
self.assertEqual(req['query_params'], {'fields': 'id'})

def test_exists_hit_w_alternate_client(self):
PATH = 'projects/%s/datasets/%s' % (self.PROJECT, self.DS_NAME)
Expand All @@ -207,6 +208,7 @@ def test_exists_hit_w_alternate_client(self):
req = conn2._requested[0]
self.assertEqual(req['method'], 'GET')
self.assertEqual(req['path'], '/%s' % PATH)
self.assertEqual(req['query_params'], {'fields': 'id'})

def test_reload_w_bound_client(self):
PATH = 'projects/%s/datasets/%s' % (self.PROJECT, self.DS_NAME)
Expand Down

0 comments on commit 43bafba

Please sign in to comment.