Upgrade django-cte from 1.3.3 to 5.x

Ouverte
#6,444 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
30/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
django, python
Domaine
backend, databases

Piste de recherche

Read the django-cte 2.x+ usage guide and the listed call sites, starting with contentcuration/db/models/query.py and contentcuration/db/models/manager.py; review the closed bump in #6435 for its failing tests. After the Django 4.2 upgrade, migrate the imports and CTE API, then run pytest and add coverage for the WithValues/RIGHT_JOIN query and each _join_type=LOUTER call site, confirming they return the same rows.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

dependencies DEV: backend

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Dependabot PR #6435 bumped django-cte from 1.3.3 to 5.0.1. That PR was closed because every release from 2.0.0 on supports only Django 4.2 to 6.1, and Studio pins django==3.2.24. This upgrade waits on the Django 4.2 upgrade. Once Django is upgraded, the bump also needs Studio's CTE code moved to the 2.x+ API.

Complexity: Medium
Target branch: unstable

Context
  • On Django 3.2, the Python tests in #6435 fail with:
    TypeError: Query.get_compiler() got an unexpected keyword argument 'elide_empty'
    
  • In 5.0.1, django_cte/query.py calls cte.query.get_compiler(connection=..., elide_empty=...) unconditionally.
  • Studio's WithValuesQuery.get_compiler(self, using=None, connection=None) in contentcuration/db/models/query.py does not accept elide_empty, so it fails with that error even on Django 4.2.
  • contentcuration/db/models/query.py subclasses django_cte.With to add RIGHT JOIN (With, WithValues). CustomTreeQuerySet and CustomManager (db/models/manager.py) build on CTEQuerySet.
  • Code that imports With, CTEQuerySet or CTEManager from django_cte (all deprecated in 2.0.0, where With became CTE and with_cte became a standalone function):
    • contentcuration/models.py
    • contentcuration/db/models/query.py, db/models/manager.py
    • contentcuration/node_metadata/cte.py
    • contentcuration/utils/recommendations.py, utils/csv_writer.py
    • contentcuration/views/base.py, views/nodes.py
    • contentcuration/viewsets/channel.py, viewsets/contentnode.py, viewsets/sync/endpoint.py
    • management/commands/fix_missing_import_sources.py, management/commands/mark_incomplete.py
    • kolibri_public/management/commands/rectify_incorrect_contentnode_source_fields.py
  • On Django ≥ 5.2 two more changes apply: in 3.0.0, _join_type=LOUTER joins that pull in a related table become LEFT OUTER instead of INNER (used in mark_incomplete.py, node_metadata/cte.py, utils/csv_writer.py), and in 2.0.0, .values() names must match the cte.col references.
  • Studio passes no materialized= argument, so the 5.0.0 NOT MATERIALIZED change does not apply.
  • django-cte 4.0.0 requires Python ≥ 3.10, which Studio's CI already uses.
The Change
  • Studio should run on django-cte 5.x with no deprecated django-cte API left in its code.
  • The custom RIGHT JOIN and VALUES CTEs should keep producing the same SQL results on the new API.
  • The bump and the call-site migration should land in one PR.
Acceptance Criteria
  • requirements.in and requirements.txt pin django-cte 5.x.
  • No module imports With, CTEQuerySet or CTEManager from django_cte.
  • pytest passes with no django-cte deprecation warnings.
  • The tag WithValues / RIGHT_JOIN query in viewsets/contentnode.py returns the same rows as before the upgrade, and a test covers it.
  • On the Django version Studio runs, each _join_type=LOUTER call site keeps the same rows it returned before the upgrade, and a test covers each one.
References

AI usage

rtibblesbot (Claude Code) reviewed #6435, read django-cte's source at v1.3.3, v2.0.0 and v5.0.1, and drafted this issue.

Filed from #6435's review.

Langage dominant
JavaScript
Étoiles
214
Forks
327
Merge moyen
17 h 5 min
PR mergées (30 j)
25

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de learningequality/studio

Toutes les issues de learningequality/studio

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.