[Python-modules-commits] [python-django-jsonfield] 01/01: Add patch to avoid failures with PostgreSQL >= 9.4.
Raphaël Hertzog
hertzog at moszumanska.debian.org
Tue Jun 28 15:58:44 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 dc921cd86899050664bd3976f38ddcb4cfcd111c
Author: Raphaël Hertzog <hertzog at debian.org>
Date: Tue Jun 28 17:45:44 2016 +0200
Add patch to avoid failures with PostgreSQL >= 9.4.
---
debian/changelog | 6 +++
...ostgreSQL-backend-to-not-do-JSON-decoding.patch | 47 ++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 54 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 195cbcb..5e7de92 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-django-jsonfield (1.0.0-2) unstable; urgency=medium
+
+ * Add patch to avoid failures with PostgreSQL >= 9.4.
+
+ -- Raphaël Hertzog <hertzog at debian.org> Tue, 28 Jun 2016 17:44:54 +0200
+
python-django-jsonfield (1.0.0-1) unstable; urgency=medium
* New upstream version. Compatible with Django 1.8 and 1.9 without warnings.
diff --git a/debian/patches/Configure-PostgreSQL-backend-to-not-do-JSON-decoding.patch b/debian/patches/Configure-PostgreSQL-backend-to-not-do-JSON-decoding.patch
new file mode 100644
index 0000000..fc0e27d
--- /dev/null
+++ b/debian/patches/Configure-PostgreSQL-backend-to-not-do-JSON-decoding.patch
@@ -0,0 +1,47 @@
+From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <hertzog at debian.org>
+Date: Fri, 24 Jun 2016 23:29:06 +0200
+Subject: Configure PostgreSQL backend to not do JSON decoding
+
+With Psycopg >= 2.5.4, "jsonb" fields are returned directly under a
+decoded form and we are not ready for that. Use
+psycopg2.extras.register_default_jsonb() to disable this behaviour on
+Django managed connections.
+
+Bug: https://bitbucket.org/schinckel/django-jsonfield/issues/53/typeerror-when-using-version-100-with
+Applied-Upstream: https://bitbucket.org/schinckel/django-jsonfield/commits/221c256824d495bde6dba17a66b0beeaa56287de
+---
+ jsonfield/fields.py | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/jsonfield/fields.py b/jsonfield/fields.py
+index 551b6eb..befef2c 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.backends.signals import connection_created
+ from django.utils.translation import ugettext_lazy as _
+ from django.utils import six
+
+@@ -150,3 +151,19 @@ class TypedJSONField(JSONField):
+ else:
+ v(value)
+
++
++def configure_database_connection(connection, **kwargs):
++ if connection.vendor != 'postgresql':
++ return
++
++ # Ensure that psycopg does not do JSON decoding under the hood
++ # We want to be able to do our own decoding with our own options
++ import psycopg2.extras
++ if hasattr(psycopg2.extras, 'register_default_jsonb'):
++ psycopg2.extras.register_default_jsonb(
++ connection.connection,
++ globally=False,
++ loads=lambda x: x)
++
++
++connection_created.connect(configure_database_connection)
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..f305046
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+Configure-PostgreSQL-backend-to-not-do-JSON-decoding.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