From 49bc54c415b75300be889b7a8fed8e3cec1c0090 Mon Sep 17 00:00:00 2001 From: Rodolpho Pivetta Sabino Date: Tue, 17 Oct 2017 10:18:49 -0200 Subject: [PATCH 1/3] #61 add support to shallow param --- firebase_admin/db.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firebase_admin/db.py b/firebase_admin/db.py index d6f5f99f0..473999749 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -125,11 +125,12 @@ def child(self, path): full_path = self._pathurl + '/' + path return Reference(client=self._client, path=full_path) - def get(self, etag=False): + def get(self, etag=False, shallow=False): """Returns the value, and optionally the ETag, at the current location of the database. Args: etag: A boolean indicating whether the Etag value should be returned or not (optional). + shallow: A boolean indicating whether the result will be shallow or not (optional). Returns: object: If etag is False returns the decoded JSON value of the current database location. @@ -141,10 +142,12 @@ def get(self, etag=False): """ if etag: headers, data = self._client.headers_and_body( - 'get', self._add_suffix(), headers={'X-Firebase-ETag' : 'true'}) + 'get', self._add_suffix(), headers={'X-Firebase-ETag' : 'true'}, + params={'shallow': shallow}) return data, headers.get('ETag') else: - return self._client.body('get', self._add_suffix()) + return self._client.body('get', self._add_suffix(), + params={'shallow': shallow}) def get_if_changed(self, etag): """Gets data in this location only if the specified ETag does not match. From 3bc92f4cd34ba98755d258e0a039f38409a99317 Mon Sep 17 00:00:00 2001 From: Rodolpho Pivetta Sabino Date: Tue, 17 Oct 2017 11:48:42 -0200 Subject: [PATCH 2/3] #61 shallow param adjustment to pass tests --- firebase_admin/db.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firebase_admin/db.py b/firebase_admin/db.py index 473999749..16c16fdea 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -140,14 +140,15 @@ def get(self, etag=False, shallow=False): Raises: ApiCallError: If an error occurs while communicating with the remote database server. """ + params = {'shallow': shallow} if shallow else None if etag: headers, data = self._client.headers_and_body( 'get', self._add_suffix(), headers={'X-Firebase-ETag' : 'true'}, - params={'shallow': shallow}) + params=params) return data, headers.get('ETag') else: return self._client.body('get', self._add_suffix(), - params={'shallow': shallow}) + params=params) def get_if_changed(self, etag): """Gets data in this location only if the specified ETag does not match. From 13b6be73a6ff6935f989913802239bb2d6bb0ec0 Mon Sep 17 00:00:00 2001 From: Rodolpho Pivetta Sabino Date: Fri, 3 Nov 2017 10:35:45 -0200 Subject: [PATCH 3/3] correction in the indentation --- firebase_admin/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firebase_admin/db.py b/firebase_admin/db.py index 16c16fdea..03bbabaf3 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -147,8 +147,8 @@ def get(self, etag=False, shallow=False): params=params) return data, headers.get('ETag') else: - return self._client.body('get', self._add_suffix(), - params=params) + return self._client.body( + 'get', self._add_suffix(), params=params) def get_if_changed(self, etag): """Gets data in this location only if the specified ETag does not match.