doableware / djongo

Django and MongoDB database connector
https://www.djongomapper.com
GNU Affero General Public License v3.0
1.86k stars 352 forks source link

Update base._close for pymongo bool() eval change #611

Closed 23pointsNorth closed 2 years ago

23pointsNorth commented 2 years ago

With the new pymongo, the evaluation to bool has been removed. Currently, the django+djongo stack results in:

server              |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 319, in close
server              |     self._close()
server              |   File "/usr/local/lib/python3.8/site-packages/djongo/base.py", line 208, in _close
server              |     if self.connection:
server              |   File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 1021, in __bool__
server              |     raise NotImplementedError(
server              | NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None

This PR directly addresses the suggestion from pymongo in checking the value to None, rather than implicitly casting to bool.

This is aimed at #585.

pederjohnsen commented 1 year ago

@nesdis any idea when we'll get a new version with this fix in it?

nesdis commented 1 year ago

you can download the latest version on djongo from github directly