From d1e25796e925d25dbf83e47c8f27c0f81477f4be Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 27 May 2013 10:41:57 -0500 Subject: [PATCH] fixed Issue 1505:Json fields imported from csv do not work with postgresql, thanks anonoofish --- VERSION | 2 +- gluon/dal.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a2c9593b..cbf0c4a1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.7-stable+timestamp.2013.05.27.10.36.47 +Version 2.4.7-stable+timestamp.2013.05.27.10.41.10 diff --git a/gluon/dal.py b/gluon/dal.py index f44ed79d..316bd133 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -2672,7 +2672,9 @@ class PostgreSQLAdapter(BaseAdapter): elif self.driver_name == "zxJDBC": supports_json = self.connection.dbversion >= "9.2.0" else: supports_json = None - if supports_json: self.types["json"] = "JSON" + if supports_json: + self.types["json"] = "JSON" + self.native_json = True else: LOGGER.debug("Your database version does not support the JSON data type (using TEXT instead)") def LIKE(self,first,second): @@ -8709,6 +8711,12 @@ class Table(object): value = None elif field.type=='blob': value = base64.b64decode(value) + elif field.type=='json': + try: + json = serializers.json + value = json(value) + except TypeError: + pass elif field.type=='double' or field.type=='float': if not value.strip(): value = None