Repository: firebase/firebase-admin-python

Issue:
Unable to query by boolean False

  * Operating System version: OSX 10.11.4
  * Firebase SDK version: Firebase Admin Python SDK 2.4.0
  * Firebase Product: database


In firebase-admin-python/firebase_admin/db.py , it's unable to use equal_to(), start_at(), and end_at() with a boolean False value. It throws `ValueError: Equal to value must not be empty or None.`

Suggest the condition of False boolean value to be catered.


Discussion:

Patch:
diff --git a/firebase_admin/db.py b/firebase_admin/db.py
index d6f5f99..1efa31e 100644
--- a/firebase_admin/db.py
+++ b/firebase_admin/db.py
@@ -442,10 +442,10 @@ class Query(object):
           Query: The updated Query instance.
 
         Raises:
-          ValueError: If the value is empty or None.
+          ValueError: If the value is None.
         """
-        if not start:
-            raise ValueError('Start value must not be empty or None.')
+        if start is None:
+            raise ValueError('Start value must not be None.')
         self._params['startAt'] = json.dumps(start)
         return self
 
@@ -462,10 +462,10 @@ class Query(object):
           Query: The updated Query instance.
 
         Raises:
-          ValueError: If the value is empty or None.
+          ValueError: If the value is None.
         """
-        if not end:
-            raise ValueError('End value must not be empty or None.')
+        if end is None:
+            raise ValueError('End value must not be None.')
         self._params['endAt'] = json.dumps(end)
         return self
 
@@ -481,10 +481,10 @@ class Query(object):
           Query: The updated Query instance.
 
         Raises:
-          ValueError: If the value is empty or None.
+          ValueError: If the value is None.
         """
-        if not value:
-            raise ValueError('Equal to value must not be empty or None.')
+        if value is None:
+            raise ValueError('Equal to value must not be None.')
         self._params['equalTo'] = json.dumps(value)
         return self
 


Test patch:
diff --git a/tests/test_db.py b/tests/test_db.py
index 98be17a..79547c2 100644
--- a/tests/test_db.py
+++ b/tests/test_db.py
@@ -694,16 +694,31 @@ class TestQuery(object):
         with pytest.raises(ValueError):
             query.start_at(None)
 
+    @pytest.mark.parametrize('arg', ['', 'foo', True, False, 0, 1, dict()])
+    def test_valid_start_at(self, arg):
+        query = self.ref.order_by_child('foo').start_at(arg)
+        assert query._querystr == 'orderBy="foo"&startAt={0}'.format(json.dumps(arg))
+
     def test_end_at_none(self):
         query = self.ref.order_by_child('foo')
         with pytest.raises(ValueError):
             query.end_at(None)
 
+    @pytest.mark.parametrize('arg', ['', 'foo', True, False, 0, 1, dict()])
+    def test_valid_end_at(self, arg):
+        query = self.ref.order_by_child('foo').end_at(arg)
+        assert query._querystr == 'endAt={0}&orderBy="foo"'.format(json.dumps(arg))
+
     def test_equal_to_none(self):
         query = self.ref.order_by_child('foo')
         with pytest.raises(ValueError):
             query.equal_to(None)
 
+    @pytest.mark.parametrize('arg', ['', 'foo', True, False, 0, 1, dict()])
+    def test_valid_equal_to(self, arg):
+        query = self.ref.order_by_child('foo').equal_to(arg)
+        assert query._querystr == 'equalTo={0}&orderBy="foo"'.format(json.dumps(arg))
+
     def test_range_query(self, initquery):
         query, order_by = initquery
         query.start_at(1)