mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed #32226 -- Fixed JSON format of QuerySet.explain() on PostgreSQL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
b3b04ad211
commit
aba9c2de66
@@ -1,4 +1,5 @@
|
||||
import collections
|
||||
import json
|
||||
import re
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
@@ -1250,9 +1251,10 @@ 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_format == 'json' else str
|
||||
for row in result[0]:
|
||||
if not isinstance(row, str):
|
||||
yield ' '.join(str(c) for c in row)
|
||||
yield ' '.join(output_formatter(c) for c in row)
|
||||
else:
|
||||
yield row
|
||||
|
||||
|
||||
Reference in New Issue
Block a user