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

Subscribers

People subscribed via source and target branches

to all changes: