Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #32226 QuerySet.explain(format='json') outputs repr'd JSON on PostgreSQL #13867

Closed
wants to merge 22 commits into from
Closed

Conversation

Uday-kiran007
Copy link

No description provided.

@Uday-kiran007 Uday-kiran007 reopened this Jan 9, 2021
@Uday-kiran007 Uday-kiran007 changed the title t Fixed #32226 QuerySet.explain(format='json') outputs repr'd JSON on PostgreSQL Jan 9, 2021
@Uday-kiran007
Copy link
Author

@felixxm could you please check and review ?

@adamchainz
Copy link
Sponsor Member

Please don't @ the fellows for review. They review tickets that are marked as ready on trac in time.

You have test failures and merge conflicts. Please rebase the branch to fix the conflicts and address the test failures.

return '\n'.join(compiler.explain_query())
if connection.vendor == 'postgresql':
if format == 'json':
return json.loads(json.dumps(ast.literal_eval('\n'.join(compiler.explain_query()))))[0]
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the ast.literal_eval approach is the best. I only included the code as an example on the ticket. It would be better to never force the result into a string in the first place.

@ngnpope ngnpope mentioned this pull request Feb 28, 2021
@felixxm felixxm closed this Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants