Repository: googleapis/python-datastore

Issue:
datastore Key id_or_name() returns None when id is 0
#### Description 
Expecting the Key().is_partial to return False for a Key with id=0.
The is_partial property relies on the id_or_name property.
The id_or_name property returns None when the id=0, which is not expected. Expecting the id to be returned instead.
The id_or_name property implementation is to simple. Should check for None or isinstance(self.id, int)

#### Environment details

  - OS type and version: Ubuntu 20.04
  - Python version: Python 3.8.5
  - pip version: pip 20.2.3
  - `google-cloud-datastore` version: 1.15.3

#### Steps to reproduce

1. Create a datastore key instance with Id = 0
2. Retrieve the id_or_name property, returns None, expected 0.

#### Code example

```python
def test_datastore_key():
    import google.cloud.datastore
    k = google.cloud.datastore.Key('EntityKind', 0, project="unittest")
    assert k.id == 0
    assert k.id_or_name == 0
    assert k.is_partial == False
```

#### Stack trace
```
assert None == 0
  +None
  -0
def test_datastore_key():
        import google.cloud.datastore
        k = google.cloud.datastore.Key('EntityKind', 0, project="unittest")
        assert k.id == 0
>       assert k.id_or_name == 0
E       assert None == 0
E         +None
E         -0
```


Discussion:
chrisrossi: Does Datastore let you store a key with id of ``0``?
HemangChothani: @chrisrossi Library doesn't stop or raise error when passing id =0 but  `if id is  0, generate automatically` as mentioned in document [here](https://cloud.google.com/appengine/docs/standard/go111/datastore/creating-entity-keys#specifying_a_key_name_for_an_entity)
chrisrossi: > @chrisrossi Library doesn't raise an error when passing id =0 but `if id is 0, generate automatically` as mentioned in document [here](https://cloud.google.com/appengine/docs/standard/go111/datastore/creating-entity-keys#specifying_a_key_name_for_an_entity)

Fair enough! This looks good to me, but I would probably add a regression test.
tseaver: @crwilcox, @czahedi Again, the `requiresCodeOwnerReviews: true` policy means my approval is not sufficient to merge this PR.

Patch:
diff --git a/google/cloud/datastore/key.py b/google/cloud/datastore/key.py
index d03359b..c9beaeb 100644
--- a/google/cloud/datastore/key.py
+++ b/google/cloud/datastore/key.py
@@ -441,7 +441,9 @@ class Key(object):
         :returns: The last element of the key's path if it is either an ``id``
                   or a ``name``.
         """
-        return self.id or self.name
+        if self.id is None:
+            return self.name
+        return self.id
 
     @property
     def project(self):


Test patch:
diff --git a/tests/unit/test_key.py b/tests/unit/test_key.py
index 73565ea..9d130fb 100644
--- a/tests/unit/test_key.py
+++ b/tests/unit/test_key.py
@@ -488,6 +488,11 @@ class TestKey(unittest.TestCase):
         key = self._make_one("KIND", _NAME, project=self._DEFAULT_PROJECT)
         self.assertEqual(key.id_or_name, _NAME)
 
+    def test_id_or_name_w_id_zero(self):
+        _ID = 0
+        key = self._make_one("KIND", _ID, project=self._DEFAULT_PROJECT)
+        self.assertEqual(key.id_or_name, _ID)
+
     def test_parent_default(self):
         key = self._make_one("KIND", project=self._DEFAULT_PROJECT)
         self.assertIsNone(key.parent)