Skip to content

Fix .explain() in Django >=4.0#91

Merged
millerdev merged 1 commit intodimagi:masterfrom
SupImDos:master
May 8, 2024
Merged

Fix .explain() in Django >=4.0#91
millerdev merged 1 commit intodimagi:masterfrom
SupImDos:master

Conversation

@SupImDos
Copy link
Contributor

@SupImDos SupImDos commented May 8, 2024

It looks like there was a change in Django 4.0 that broke the django-cte explain functionality.

See:

This wasn't picked up by the unit tests because we manually set explain_query = True (which is now unused) rather than call the .explain() queryset method.

This PR adds some logic to retrieve explain_query for Django < 4.0, and explain_info for Django >= 4.0. It also updates the unit tests to call .explain() (which appears to work on sqlite3 as far as I can tell).

There's probably a cleaner way to do this, so feel free rework if you see fit.

@millerdev millerdev merged commit 744d745 into dimagi:master May 8, 2024
@millerdev
Copy link
Contributor

Thank you for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants