Skip to content

Django 6.1 support - #143

Merged
millerdev merged 3 commits into
dimagi:mainfrom
heinrichf-cdgnm:django-6.1-compat
Aug 12, 2026
Merged

millerdev merged 3 commits into
dimagi:mainfrom
heinrichf-cdgnm:django-6.1-compat

Conversation

@heinrichf-cdgnm

Copy link
Copy Markdown
Contributor

Django 6.1 (ticket #36795) made SQLCompiler.quote_name() quote table aliases and deprecated quote_name_unless_alias(), which did not. QJoin.as_sql() never quoted its alias, so a CTE joined inside a subquery, where the alias is prefix-bumped and no longer matches the CTE name, mixed a bare alias with quoted references to it: JOIN "cte" U2 ON "U2"."id" = .... PostgreSQL case-folds the former but not the latter, raising missing FROM-clause entry for table "U2".

This fixes test_raw_cte_subquery and test_alias_as_subquery (v1 and current), which already fail on Django 6.1, and adds a test for the join alias. Generated SQL is unchanged on Django < 6.1, where the alias stays bare to match what Django itself emits.

The test matrix is derived from the Framework :: Django classifiers, so 6.1 was never exercised. Added it there and as a tox factor.

@millerdev
millerdev enabled auto-merge August 12, 2026 15:24
@millerdev
millerdev merged commit d83f0b9 into dimagi:main Aug 12, 2026
23 checks passed
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