Merge ~lvoytek/ubuntu/+source/django-cte:django4-compatibility into ubuntu/+source/django-cte:ubuntu/devel

Proposed by Lena Voytek
Status: Merged
Approved by: git-ubuntu bot
Approved revision: not available
Merged at revision: ab0bc3e082e499e84774b3032c548cfae039120b
Proposed branch: ~lvoytek/ubuntu/+source/django-cte:django4-compatibility
Merge into: ubuntu/+source/django-cte:ubuntu/devel
Diff against target: 71 lines (+41/-1)
4 files modified
debian/changelog (+8/-0)
debian/control (+2/-1)
debian/patches/fix-column-alias-django4.patch (+30/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
git-ubuntu bot Approve
Lukas Märdian (community) Approve
Canonical Server Pending
Canonical Server Reporter Pending
Review via email: mp+450369@code.launchpad.net

Description of the change

Fix Django 4.2 compatibility by ignoring generated SQL aliases. This is currently the easiest fix for the new version, but will likely be different when updated upstream. I noted in the patch that it should be removed once a new upstream version with the fix is merged in.

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

local autopkgtest results:

autopkgtest [10:30:45]: @@@@@@@@@@@@@@@@@@@@ summary
run-tests PASS
qemu-system-x86_64: terminating on signal 15 from pid 36401 (/usr/bin/python3)

To post a comment you must log in.
Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you very much!

This is a simple and clean patch, using proper DEP-3 headers and evidence was provided that the code had been properly tested (PPA build + local autopkgtests).

Your comment in the patch description about an alternative upstream solution is also a good hint for the future.

LGTM!

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

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

review: Approve
Revision history for this message
Lukas Märdian (slyon) wrote :

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 6c316b0..297ec1f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+django-cte (1.3.0-1ubuntu1) mantic; urgency=medium
7+
8+ * d/p/fix-column-alias-django4.patch: Remove SQL column aliases as a
9+ workaround for Django 4 introducing aliases that break access to
10+ rootmap.name (LP: #2022089)
11+
12+ -- Lena Voytek <lena.voytek@canonical.com> Thu, 31 Aug 2023 09:19:08 -0700
13+
14 django-cte (1.3.0-1) unstable; urgency=medium
15
16 * New upstream release.
17diff --git a/debian/control b/debian/control
18index fa8da4c..ab25f13 100644
19--- a/debian/control
20+++ b/debian/control
21@@ -1,5 +1,6 @@
22 Source: django-cte
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: Edward Betts <edward@4angle.com>
27 Section: python
28 Priority: optional
29diff --git a/debian/patches/fix-column-alias-django4.patch b/debian/patches/fix-column-alias-django4.patch
30new file mode 100644
31index 0000000..03828db
32--- /dev/null
33+++ b/debian/patches/fix-column-alias-django4.patch
34@@ -0,0 +1,30 @@
35+Description: Do not use Django 4.2 column aliases so rootmap.name is accessible
36+ When Django 4.2 was released, it added a commit that generated explicit
37+ aliases in generated SQL. This leads to a situation in the current version of
38+ django-cte where query executions fail due to rootmap's "name" attribute being
39+ aliased to "col1". There is an ongoing discussion as to how to move forward
40+ with this in future django-cte versions in the attached bug, but the current
41+ best workaround is to avoid using aliases when generating SQL statements in
42+ the CTEQueryCompiler class. The final solution to this will likely be
43+ different though, with some drafts in progress, such as:
44+ https://github.com/dimagi/django-cte/pull/59
45+ As such this patch will need to be removed once a newer version with the bug
46+ fixed is merged.
47+Author: Lena Voytek <lena.voytek@canonical.com>
48+Bug: https://github.com/dimagi/django-cte/issues/66
49+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/mantic/+source/django-cte/+bug/2022089
50+Forwarded: not-needed
51+Last-Update: 2023-08-31
52+---
53+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
54+--- a/django_cte/query.py
55++++ b/django_cte/query.py
56+@@ -133,6 +133,8 @@
57+ class CTEQueryCompiler(SQLCompiler):
58+
59+ def as_sql(self, *args, **kwargs):
60++ with_col_aliases = kwargs.pop('with_col_aliases', None)
61++
62+ def _as_sql():
63+ return super(CTEQueryCompiler, self).as_sql(*args, **kwargs)
64+ return CTECompiler.generate_sql(self.connection, self.query, _as_sql)
65diff --git a/debian/patches/series b/debian/patches/series
66new file mode 100644
67index 0000000..0f456fa
68--- /dev/null
69+++ b/debian/patches/series
70@@ -0,0 +1 @@
71+fix-column-alias-django4.patch

Subscribers

People subscribed via source and target branches

to all changes: