[Python-modules-commits] [python-django-jsonfield] 01/01: Add patch for Django 1.10 compatility. Closes: #828668
Raphaël Hertzog
hertzog at moszumanska.debian.org
Thu Aug 18 12:27:53 UTC 2016
This is an automated email from the git hooks/post-receive script.
hertzog pushed a commit to branch master
in repository python-django-jsonfield.
commit 7d3008b9aa0e3ee3381e08c437393c34fe001df8
Author: Raphaël Hertzog <hertzog at debian.org>
Date: Thu Aug 18 14:25:02 2016 +0200
Add patch for Django 1.10 compatility. Closes: #828668
---
debian/changelog | 6 ++
debian/patches/django-1.10-compat.patch | 99 +++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 106 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 3114c15..3ced85f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-django-jsonfield (1.0.1-2) unstable; urgency=medium
+
+ * Add patch for Django 1.10 compatility. Closes: #828668
+
+ -- Raphaël Hertzog <hertzog at debian.org> Thu, 18 Aug 2016 14:21:22 +0200
+
python-django-jsonfield (1.0.1-1) unstable; urgency=medium
* New upstream release incorporating the latest patch for proper support of
diff --git a/debian/patches/django-1.10-compat.patch b/debian/patches/django-1.10-compat.patch
new file mode 100644
index 0000000..c0a9d2f
--- /dev/null
+++ b/debian/patches/django-1.10-compat.patch
@@ -0,0 +1,99 @@
+From 68a74fd8f5cc0ce0778bda680b3ca005e68b9530 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog at debian.org>
+Date: Thu, 18 Aug 2016 14:14:44 +0200
+Subject: Register explicit lookup operators
+
+Django 1.10 dropped support for Field.get_prep_lookup() and we need
+to register explicit lookup operators overriding the default operators
+to have our desired behaviour.
+
+Fix #56
+
+Bug: https://bitbucket.org/schinckel/django-jsonfield/issues/56/unit-test-test_query_object-fails-with
+Bug-Debian: https://bugs.debian.org/828668
+Applied-Upstream: 1.0.2
+---
+ jsonfield/fields.py | 59 +++++++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 44 insertions(+), 15 deletions(-)
+
+diff --git a/jsonfield/fields.py b/jsonfield/fields.py
+index befef2c..dd390ef 100644
+--- a/jsonfield/fields.py
++++ b/jsonfield/fields.py
+@@ -4,6 +4,7 @@ import json
+ from django.core.exceptions import ValidationError
+ from django.conf import settings
+ from django.db import models
++from django.db.models.lookups import Exact, IExact, In, Contains, IContains
+ from django.db.backends.signals import connection_created
+ from django.utils.translation import ugettext_lazy as _
+ from django.utils import six
+@@ -95,25 +96,53 @@ class JSONField(models.Field):
+ return None
+ return json.dumps(value, **self.encoder_kwargs)
+
+- def get_prep_lookup(self, lookup_type, value):
+- if lookup_type in ["exact", "iexact", "in", "isnull"]:
+- return value
+- if lookup_type in ["contains", "icontains"]:
+- if isinstance(value, (list, tuple)):
+- raise TypeError("Lookup type %r not supported with argument of %s" % (
+- lookup_type, type(value).__name__
+- ))
+- # Need a way co combine the values with '%', but don't escape that.
+- return self.get_prep_value(value)[1:-1].replace(', ', r'%')
+- if isinstance(value, dict):
+- return self.get_prep_value(value)[1:-1]
+- return self.get_prep_value(value)
+- raise TypeError('Lookup type %r not supported' % lookup_type)
+-
+ def value_to_string(self, obj):
+ return self._get_val_from_obj(obj)
+
+
++class NoPrepareMixin(object):
++ def get_prep_lookup(self):
++ return self.rhs
++
++
++class JSONFieldExactLookup(NoPrepareMixin, Exact):
++ pass
++
++
++class JSONFieldIExactLookup(NoPrepareMixin, IExact):
++ pass
++
++
++class JSONFieldInLookup(NoPrepareMixin, In):
++ pass
++
++
++class ContainsLookupMixin(object):
++ def get_prep_lookup(self):
++ if isinstance(self.rhs, (list, tuple)):
++ raise TypeError("Lookup type %r not supported with %s argument" % (
++ self.lookup_name, type(self.rhs).__name__
++ ))
++ if isinstance(self.rhs, dict):
++ return self.lhs.output_field.get_prep_value(self.rhs)[1:-1]
++ return self.lhs.output_field.get_prep_value(self.rhs)
++
++
++class JSONFieldContainsLookup(ContainsLookupMixin, Contains):
++ pass
++
++
++class JSONFieldIContainsLookup(ContainsLookupMixin, IContains):
++ pass
++
++
++JSONField.register_lookup(JSONFieldExactLookup)
++JSONField.register_lookup(JSONFieldIExactLookup)
++JSONField.register_lookup(JSONFieldInLookup)
++JSONField.register_lookup(JSONFieldContainsLookup)
++JSONField.register_lookup(JSONFieldIContainsLookup)
++
++
+ class TypedJSONField(JSONField):
+ """
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..a6dd669
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+django-1.10-compat.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-jsonfield.git
More information about the Python-modules-commits
mailing list