Skip to content

Commit 7c93839

Browse files
committed
Fix: pytest-dev#50, broken exception handling in _swap_database()
1 parent 120b0c3 commit 7c93839

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

peewee_async.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,12 @@ def _swap_database(self, query):
351351
"""Swap database for query if swappable. Return **new query**
352352
with swapped database.
353353
354-
Check manager database and model database match. If model
355-
database is `auto`, manager's one will be used.
354+
This is experimental feature which allows us to have multiple
355+
managers configured against different databases for single model
356+
definition.
356357
357-
If query database can't be swapped and differs from manager's
358-
database, it's **WRONG AND DANGEROUS**, so assertion is raised.
358+
The essential limitation though is that database backend have
359+
to be **the same type** for model and manager!
359360
"""
360361
if query.database == self.database:
361362
return query
@@ -376,8 +377,12 @@ def _swap_database(self, query):
376377
query.database = self.database
377378
return query
378379
else:
379-
assert False, ("Error, models's database and manager's "
380-
"database are different: %s" % model)
380+
assert False, (
381+
"Error, query's database and manager's database are "
382+
"different. Query: %s Manager: %s" % (
383+
query.database, self.database
384+
)
385+
)
381386

382387
@staticmethod
383388
def _subclassed(base, *classes):

0 commit comments

Comments
 (0)