mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Expanded QuerySet.explain() error message if a backend supports no formats.
This commit is contained in:
parent
a32876606f
commit
db83ac48d4
@ -754,6 +754,10 @@ class BaseDatabaseOperations:
|
||||
msg = "%s is not a recognized format." % normalized_format
|
||||
if supported_formats:
|
||||
msg += " Allowed formats: %s" % ", ".join(sorted(supported_formats))
|
||||
else:
|
||||
msg += (
|
||||
f" {self.connection.display_name} does not support any formats."
|
||||
)
|
||||
raise ValueError(msg)
|
||||
if options:
|
||||
raise ValueError("Unknown options: %s" % ", ".join(sorted(options.keys())))
|
||||
|
@ -74,6 +74,8 @@ class ExplainTests(TestCase):
|
||||
msg += " Allowed formats: %s" % ", ".join(
|
||||
sorted(connection.features.supported_explain_formats)
|
||||
)
|
||||
else:
|
||||
msg += f" {connection.display_name} does not support any formats."
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
Tag.objects.explain(format="does not exist")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user