Merge ~lvoytek/ubuntu/+source/python-django-tagging:django4.2-compatibility into ubuntu/+source/python-django-tagging:ubuntu/devel

Proposed by Lena Voytek
Status: Merged
Approved by: git-ubuntu bot
Approved revision: not available
Merge reported by: Andreas Hasenack
Merged at revision: 883e3b1d71ee9184c236115d309b3d3dccd47579
Proposed branch: ~lvoytek/ubuntu/+source/python-django-tagging:django4.2-compatibility
Merge into: ubuntu/+source/python-django-tagging:ubuntu/devel
Diff against target: 99 lines (+66/-1)
4 files modified
debian/changelog (+8/-0)
debian/control (+2/-1)
debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch (+55/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
git-ubuntu bot Approve
Simon Quigley (community) Approve
Canonical Server Pending
Canonical Server Reporter Pending
Review via email: mp+449482@code.launchpad.net

Description of the change

Add a patch to allow django-tagging to work with Django 4.2 by fixing the FullResultSet exception caused during normal operation

PPA: https://launchpad.net/~lvoytek/+archive/ubuntu/django-4-mantic

The package also still builds properly with Django 3 FWIW as seen in this ppa:
https://launchpad.net/~lvoytek/+archive/ubuntu/django3-mantic

This issue has yet to be addressed upstream and has no relevant merge requests for it so I created the patch myself. I also sent a merge request to debian and notified the python team but have yet to hear back:
https://salsa.debian.org/python-team/packages/python-django-tagging/-/merge_requests/2

To post a comment you must log in.
Revision history for this message
Michał Małoszewski (michal-maloszewski99) wrote :

LGTM, +1

Revision history for this message
Simon Quigley (tsimonq2) wrote :

Given the existing +1, the packaging looks good as well. Thanks for using DEP-3 headers!

review: Approve
Revision history for this message
git-ubuntu bot (git-ubuntu-bot) wrote :

Approvers: tsimonq2, lvoytek
Uploaders: tsimonq2
MP auto-approved

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

This was uploaded and migrated into noble already, closing.

https://launchpad.net/ubuntu/+source/python-django-tagging/1:0.5.0-4ubuntu1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index f0ead9f..49494b5 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+python-django-tagging (1:0.5.0-4ubuntu1) mantic; urgency=medium
7+
8+ * d/p/django-4.x-fixes/Check-FullResultSet-exception.patch: Fix
9+ compatibility with Django 4 by handling FullResultSet exception introduced
10+ in version 4.2 (LP: #2022089)
11+
12+ -- Lena Voytek <lena.voytek@canonical.com> Fri, 18 Aug 2023 14:32:42 -0700
13+
14 python-django-tagging (1:0.5.0-4) unstable; urgency=medium
15
16 * Team upload.
17diff --git a/debian/control b/debian/control
18index 817d5e0..2137abe 100644
19--- a/debian/control
20+++ b/debian/control
21@@ -1,5 +1,6 @@
22 Source: python-django-tagging
23-Maintainer: Debian Python Team <team+python@tracker.debian.org>
24+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
25+XSBC-Original-Maintainer: Debian Python Team <team+python@tracker.debian.org>
26 Uploaders:
27 Jonas Genannt <genannt@debian.org>,
28 Christopher Baines <mail@cbaines.net>,
29diff --git a/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch b/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch
30new file mode 100644
31index 0000000..f01aabb
32--- /dev/null
33+++ b/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch
34@@ -0,0 +1,55 @@
35+Description: Ignore FullResultSet exception introduced in Django 4.2
36+ As of version 4.2 Django added an exception during query generation when a
37+ query matches everything contained in a table. Since the
38+ models.usage_for_queryset function is meant to handle this case, this patch
39+ instead uses the exception to determine if extra criteria are required. This
40+ effectively replaces the if statement that determines if a "where" value was
41+ generated. The if statement is maintained along with the ImportError skip to
42+ keep compatibility with older Django versions.
43+Author: Lena Voytek <lena.voytek@canonical.com>
44+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-django-tagging/+bug/2022089
45+Last-Update: 2023-08-01
46+---
47+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
48+--- a/tagging/models.py
49++++ b/tagging/models.py
50+@@ -9,6 +9,12 @@
51+ from django.utils.encoding import smart_str
52+ from django.utils.translation import gettext_lazy as _
53+
54++# FullResultSet exception is new to Django 4.2
55++try:
56++ from django.core.exceptions import FullResultSet
57++except ImportError:
58++ pass
59++
60+ from tagging import settings
61+ from tagging.utils import LOGARITHMIC
62+ from tagging.utils import calculate_cloud
63+@@ -177,13 +183,21 @@
64+ Passing a value for ``min_count`` implies ``counts=True``.
65+ """
66+ compiler = queryset.query.get_compiler(using=queryset.db)
67+- where, params = compiler.compile(queryset.query.where)
68+- extra_joins = ' '.join(compiler.get_from_clause()[0][1:])
69++ params = []
70++
71++ try:
72++ where, params = compiler.compile(queryset.query.where)
73++
74++ if where:
75++ extra_criteria = 'AND %s' % where
76++ else:
77++ extra_criteria = ''
78+
79+- if where:
80+- extra_criteria = 'AND %s' % where
81+- else:
82++ except FullResultSet:
83+ extra_criteria = ''
84++
85++ extra_joins = ' '.join(compiler.get_from_clause()[0][1:])
86++
87+ return self._get_usage(queryset.model, counts, min_count,
88+ extra_joins, extra_criteria, params)
89+
90diff --git a/debian/patches/series b/debian/patches/series
91index 9c3c21a..608099b 100644
92--- a/debian/patches/series
93+++ b/debian/patches/series
94@@ -2,4 +2,5 @@ Use-local-inventory-for-intersphinx.patch
95 django-4.x-fixes/Use-smart_str-instead-of-deprecated-smart_text-Django-fun.patch
96 django-4.x-fixes/Use-re_path-instead-of-deprecated-url-Django-function.patch
97 django-4.x-fixes/Add-support-for-Django-4-compatibility.patch
98+django-4.x-fixes/Check-FullResultSet-exception.patch
99 python3.11.patch

Subscribers

People subscribed via source and target branches

to all changes: