Control: tags 994257 + patch Control: tags 994257 + pending Dear maintainer,
I've prepared an NMU for django-ldapdb (versioned as 1.5.1-2.1) and uploaded it to DELAYED/14. Please feel free to tell me if I should cancel it. cu Adrian
diff -Nru django-ldapdb-1.5.1/debian/changelog django-ldapdb-1.5.1/debian/changelog --- django-ldapdb-1.5.1/debian/changelog 2020-10-25 21:43:12.000000000 +0200 +++ django-ldapdb-1.5.1/debian/changelog 2021-11-05 18:59:37.000000000 +0200 @@ -1,3 +1,10 @@ +django-ldapdb (1.5.1-2.1) unstable; urgency=medium + + * Non-maintainer upload. + * Add upstream patches for Django 3.2 support. (Closes: #994257) + + -- Adrian Bunk <b...@debian.org> Fri, 05 Nov 2021 18:59:37 +0200 + django-ldapdb (1.5.1-2) unstable; urgency=medium * Run manage_dev.py for CI tests (Closes: #972874). diff -Nru django-ldapdb-1.5.1/debian/patches/0001-Use-get_attname-instead-of-attname-attribute.patch django-ldapdb-1.5.1/debian/patches/0001-Use-get_attname-instead-of-attname-attribute.patch --- django-ldapdb-1.5.1/debian/patches/0001-Use-get_attname-instead-of-attname-attribute.patch 1970-01-01 02:00:00.000000000 +0200 +++ django-ldapdb-1.5.1/debian/patches/0001-Use-get_attname-instead-of-attname-attribute.patch 2021-11-05 18:56:58.000000000 +0200 @@ -0,0 +1,48 @@ +From 88366f356e4569a0cb9a768ccec1b544ef0d66ee Mon Sep 17 00:00:00 2001 +From: dzen <benoit.cal...@polyconseil.fr> +Date: Tue, 13 Apr 2021 16:46:32 +0200 +Subject: Use get_attname instead of attname attribute + +--- + ldapdb/backends/ldap/compiler.py | 4 ++-- + ldapdb/models/base.py | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/ldapdb/backends/ldap/compiler.py b/ldapdb/backends/ldap/compiler.py +index 4ce9f94..1d9e771 100644 +--- a/ldapdb/backends/ldap/compiler.py ++++ b/ldapdb/backends/ldap/compiler.py +@@ -231,7 +231,7 @@ class SQLCompiler(compiler.SQLCompiler): + if isinstance(e[0], aggregates.Count): + value = 0 + input_field = e[0].get_source_expressions()[0].field +- if input_field.attname == 'dn': ++ if input_field.get_attname() == 'dn': + value = 1 + elif hasattr(input_field, 'from_ldap'): + result = input_field.from_ldap( +@@ -243,7 +243,7 @@ class SQLCompiler(compiler.SQLCompiler): + value = len(result) + row.append(value) + else: +- if e[0].field.attname == 'dn': ++ if e[0].field.get_attname() == 'dn': + row.append(dn) + elif hasattr(e[0].field, 'from_ldap'): + row.append(e[0].field.from_ldap( +diff --git a/ldapdb/models/base.py b/ldapdb/models/base.py +index e4d9e15..18d3d1e 100644 +--- a/ldapdb/models/base.py ++++ b/ldapdb/models/base.py +@@ -83,7 +83,7 @@ class Model(django.db.models.base.Model): + ] + + def get_field_value(field, instance): +- python_value = getattr(instance, field.attname) ++ python_value = getattr(instance, field.get_attname()) + return field.get_db_prep_save(python_value, connection=connection) + + if create: +-- +2.20.1 + diff -Nru django-ldapdb-1.5.1/debian/patches/0002-tests-add-missing-contribute_to_class-to-fully-insta.patch django-ldapdb-1.5.1/debian/patches/0002-tests-add-missing-contribute_to_class-to-fully-insta.patch --- django-ldapdb-1.5.1/debian/patches/0002-tests-add-missing-contribute_to_class-to-fully-insta.patch 1970-01-01 02:00:00.000000000 +0200 +++ django-ldapdb-1.5.1/debian/patches/0002-tests-add-missing-contribute_to_class-to-fully-insta.patch 2021-11-05 18:56:58.000000000 +0200 @@ -0,0 +1,24 @@ +From 17d807ef5259838ea0b1b2db0382963a94296bee Mon Sep 17 00:00:00 2001 +From: dzen <benoit.cal...@polyconseil.fr> +Date: Tue, 13 Apr 2021 16:47:00 +0200 +Subject: tests: add missing contribute_to_class to fully instanciate the field + +--- + ldapdb/tests.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/ldapdb/tests.py b/ldapdb/tests.py +index f2da2d4..2aca0a0 100644 +--- a/ldapdb/tests.py ++++ b/ldapdb/tests.py +@@ -82,6 +82,7 @@ class WhereTestCase(TestCase): + def _build_lookup(self, field_name, lookup, value, field=fields.CharField): + fake_field = field() + fake_field.set_attributes_from_name(field_name) ++ fake_field.contribute_to_class(FakeModel, "fake") + lhs = expressions.Col('faketable', fake_field, fake_field) + lookup = lhs.get_lookup(lookup) + return lookup(lhs, value) +-- +2.20.1 + diff -Nru django-ldapdb-1.5.1/debian/patches/0003-Update-regex-to-be-compatible-with-django-2-to-Djang.patch django-ldapdb-1.5.1/debian/patches/0003-Update-regex-to-be-compatible-with-django-2-to-Djang.patch --- django-ldapdb-1.5.1/debian/patches/0003-Update-regex-to-be-compatible-with-django-2-to-Djang.patch 1970-01-01 02:00:00.000000000 +0200 +++ django-ldapdb-1.5.1/debian/patches/0003-Update-regex-to-be-compatible-with-django-2-to-Djang.patch 2021-11-05 18:56:58.000000000 +0200 @@ -0,0 +1,84 @@ +From d3a0b20eb53fd3e13c454499ca1771df7f8858b3 Mon Sep 17 00:00:00 2001 +From: dzen <benoit.cal...@polyconseil.fr> +Date: Tue, 13 Apr 2021 16:47:44 +0200 +Subject: Update regex to be compatible with django 2 to Django 3.2 + +--- + ldapdb/backends/ldap/compiler.py | 16 +++++++++------- + ldapdb/tests.py | 29 +++++++++++++++++++++++++++++ + 2 files changed, 38 insertions(+), 7 deletions(-) + +diff --git a/ldapdb/backends/ldap/compiler.py b/ldapdb/backends/ldap/compiler.py +index 1d9e771..970b081 100644 +--- a/ldapdb/backends/ldap/compiler.py ++++ b/ldapdb/backends/ldap/compiler.py +@@ -15,7 +15,8 @@ from ldapdb import escape_ldap_filter + from ldapdb.models.fields import ListField + + _ORDER_BY_LIMIT_OFFSET_RE = re.compile( +- r'(?:\bORDER BY\b\s+(.+?))?\s*(?:\bLIMIT\b\s+(-?\d+))?\s*(?:\bOFFSET\b\s+(\d+))?$') ++ r"(?:\bORDER BY\b\s+([\w\.]+)\s(?P<order>\bASC\b)|(\bDESC\b))\s{1,2}(?:\bLIMIT\b\s+(?P<limit>-?\d+))?[\)\s]?(?:\bOFFSET\b\s+(?P<offset>(\d+)))?" # noqa: E501 ++) + + + class LdapDBError(Exception): +@@ -146,12 +147,13 @@ class SQLCompiler(compiler.SQLCompiler): + if hasattr(self.query, 'subquery') and self.query.subquery: + sql = self.query.subquery + m = _ORDER_BY_LIMIT_OFFSET_RE.search(sql) +- limit = m.group(2) +- offset = m.group(3) +- if limit and int(limit) >= 0: +- output.append(int(limit)) +- elif offset: +- output.append(len(vals) - int(offset)) ++ if m: ++ limit = m.group('limit') ++ offset = m.group('offset') ++ if limit and int(limit) >= 0: ++ output.append(int(limit)) ++ elif offset: ++ output.append(len(vals) - int(offset)) + else: + output.append(len(vals)) + else: +diff --git a/ldapdb/tests.py b/ldapdb/tests.py +index 2aca0a0..8929126 100644 +--- a/ldapdb/tests.py ++++ b/ldapdb/tests.py +@@ -246,3 +246,32 @@ class WhereTestCase(TestCase): + where.add(self._build_lookup("cn", 'exact', "foo", field=fields.CharField), AND) + where.add(self._build_lookup("givenName", 'exact', "bar", field=fields.CharField), OR) + self.assertEqual(self._where_as_ldap(where), "(|(cn=foo)(givenName=bar))") ++ ++ ++class CompilerRegexTestCase(TestCase): ++ ++ def _run_regex(self, sql): ++ match = ldapdb_compiler._ORDER_BY_LIMIT_OFFSET_RE.search(sql) ++ self.assertIsNotNone(match) ++ return match ++ ++ def test_regex(self): ++ sql = "SELECT examples_ldapgroup.cn AS Col1 FROM examples_ldapgroup ORDER BY examples_ldapgroup.gidNumber ASC LIMIT 2" # noqa: E501 ++ match = self._run_regex(sql) ++ self.assertEqual(match.group('limit'), '2') ++ self.assertEqual(match.group('offset'), None) ++ ++ sql = "SELECT COUNT(*) FROM (SELECT examples_ldapgroup.cn AS Col1 FROM examples_ldapgroup ORDER BY examples_ldapgroup.gidNumber ASC LIMIT 2) subquery" # noqa: E501 ++ match = self._run_regex(sql) ++ self.assertEqual(match.group('limit'), '2') ++ ++ sql = "SELECT COUNT(*) FROM (SELECT examples_ldapgroup.cn AS Col1 FROM examples_ldapgroup ORDER BY examples_ldapgroup.gidNumber ASC LIMIT -1 OFFSET 1) subquery" # noqa: E501 ++ match = self._run_regex(sql) ++ self.assertEqual(match.group('limit'), '-1') ++ self.assertEqual(match.group('offset'), '1') ++ ++ def test_regex_django22(self): ++ sql = "SELECT examples_ldapgroup.cn AS Col1 FROM examples_ldapgroup ORDER BY examples_ldapgroup.gidNumber ASC LIMIT 2" # noqa: E501 ++ match = self._run_regex(sql) ++ self.assertEqual(match.group('limit'), '2') ++ self.assertEqual(match.group('offset'), None) +-- +2.20.1 + diff -Nru django-ldapdb-1.5.1/debian/patches/series django-ldapdb-1.5.1/debian/patches/series --- django-ldapdb-1.5.1/debian/patches/series 1970-01-01 02:00:00.000000000 +0200 +++ django-ldapdb-1.5.1/debian/patches/series 2021-11-05 18:59:28.000000000 +0200 @@ -0,0 +1,3 @@ +0001-Use-get_attname-instead-of-attname-attribute.patch +0002-tests-add-missing-contribute_to_class-to-fully-insta.patch +0003-Update-regex-to-be-compatible-with-django-2-to-Djang.patch