diff --git a/debian/changelog b/debian/changelog index f0ead9f3a085a3d32afa62f71b4bb71668cd7eb1..23e5a119868beead33580cf467667acda7ef8e4f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-django-tagging (1:0.5.0-5) UNRELEASED; urgency=medium + + * Add Check-FullResultSet-exception.patch to fix Django 4.2 + compatibility by handling FullResultSet exceptions + + -- Lena Voytek <lena.voytek@canonical.com> Tue, 08 Aug 2023 13:14:46 -0700 + python-django-tagging (1:0.5.0-4) unstable; urgency=medium * Team upload. diff --git a/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch b/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e7e88c9b9d132a58040510a2e4697e21d581bb7 --- /dev/null +++ b/debian/patches/django-4.x-fixes/Check-FullResultSet-exception.patch @@ -0,0 +1,54 @@ +Description: Ignore FullResultSet exception introduced in Django 4.2 + As of version 4.2 Django added an exception during query generation when a + query matches everything contained in a table. Since the + models.usage_for_queryset function is meant to handle this case, this patch + instead uses the exception to determine if extra criteria are required. This + effectively replaces the if statement that determines if a "where" value was + generated. The if statement is maintained along with the ImportError skip to + keep compatibility with older Django versions. +Author: Lena Voytek <lena.voytek@canonical.com> +Last-Update: 2023-08-01 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/tagging/models.py ++++ b/tagging/models.py +@@ -9,6 +9,12 @@ + from django.utils.encoding import smart_str + from django.utils.translation import gettext_lazy as _ + ++# FullResultSet exception is new to Django 4.2 ++try: ++ from django.core.exceptions import FullResultSet ++except ImportError: ++ pass ++ + from tagging import settings + from tagging.utils import LOGARITHMIC + from tagging.utils import calculate_cloud +@@ -177,13 +183,21 @@ + Passing a value for ``min_count`` implies ``counts=True``. + """ + compiler = queryset.query.get_compiler(using=queryset.db) +- where, params = compiler.compile(queryset.query.where) +- extra_joins = ' '.join(compiler.get_from_clause()[0][1:]) ++ params = [] ++ ++ try: ++ where, params = compiler.compile(queryset.query.where) ++ ++ if where: ++ extra_criteria = 'AND %s' % where ++ else: ++ extra_criteria = '' + +- if where: +- extra_criteria = 'AND %s' % where +- else: ++ except FullResultSet: + extra_criteria = '' ++ ++ extra_joins = ' '.join(compiler.get_from_clause()[0][1:]) ++ + return self._get_usage(queryset.model, counts, min_count, + extra_joins, extra_criteria, params) + diff --git a/debian/patches/series b/debian/patches/series index 9c3c21a00027a29fba455f7c0aeedfed230c2536..608099bddfcfdb19e1d4e6e4fd0699f02e3570f5 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,4 +2,5 @@ Use-local-inventory-for-intersphinx.patch django-4.x-fixes/Use-smart_str-instead-of-deprecated-smart_text-Django-fun.patch django-4.x-fixes/Use-re_path-instead-of-deprecated-url-Django-function.patch django-4.x-fixes/Add-support-for-Django-4-compatibility.patch +django-4.x-fixes/Check-FullResultSet-exception.patch python3.11.patch