Skip to content

Commit

Permalink
better DB handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisclark committed Feb 1, 2024
1 parent 46fe20d commit d1c409b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions constance/backends/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def get(self, key):
else:
value = None
if value is None:
try:
value = self._model._default_manager.get(key=key).value
except (OperationalError, ProgrammingError, self._model.DoesNotExist):
match = self._model._default_manager.filter(key=key)
if len(match) == 0:
pass
else:
value = match.first().value
if self._cache:
self._cache.add(key, value)
return value
Expand Down
2 changes: 1 addition & 1 deletion tests/backends/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_database_queries(self):
with self.assertNumQueries(5):
self.config.INT_VALUE

# Read again
# Read
with self.assertNumQueries(1):
self.config.INT_VALUE

Expand Down

0 comments on commit d1c409b

Please sign in to comment.