From f4f2afeb457429f55d6325ed557f8e92a74ee028 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 19 Apr 2022 08:24:24 +0200 Subject: Refs #32226 -- Fixed JSON format of QuerySet.explain() on PostgreSQL when format is uppercased. Follow up to aba9c2de669dcc0278c7ffde7981be91801be00b. --- django/db/models/sql/compiler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'django/db/models/sql/compiler.py') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 1285b647d8..13b606255c 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1434,9 +1434,8 @@ class SQLCompiler: result = list(self.execute_sql()) # Some backends return 1 item tuples with strings, and others return # tuples with integers and strings. Flatten them out into strings. - output_formatter = ( - json.dumps if self.query.explain_info.format == "json" else str - ) + format_ = self.query.explain_info.format + output_formatter = json.dumps if format_ and format_.lower() == "json" else str for row in result[0]: if not isinstance(row, str): yield " ".join(output_formatter(c) for c in row) -- cgit v1.3