From c4a4ee27c42e4e3b2458981888d6db6400657006 Mon Sep 17 00:00:00 2001 From: Niphlod Date: Sun, 14 Sep 2014 16:39:54 +0200 Subject: [PATCH] postgresql: identifies what adapter auto-loads json values --- gluon/dal.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gluon/dal.py b/gluon/dal.py index 09a41a03..2deedb08 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -2917,16 +2917,21 @@ class PostgreSQLAdapter(BaseAdapter): # (to be added to after_connection) if self.driver_name == "pg8000": supports_json = self.connection.server_version >= "9.2.0" - elif (self.driver_name == "psycopg2") and \ - (self.driver.__version__ >= "2.0.12"): + elif (self.driver_name == "psycopg2" and + self.driver.__version__ >= "2.0.12"): supports_json = self.connection.server_version >= 90200 elif self.driver_name == "zxJDBC": supports_json = self.connection.dbversion >= "9.2.0" - else: supports_json = None + else: + supports_json = None if supports_json: self.types["json"] = "JSON" - self.driver_auto_json = ['loads'] - else: LOGGER.debug("Your database version does not support the JSON data type (using TEXT instead)") + if (self.driver_name == "psycopg2" and + self.driver.__version__ >= '2.5.0'): + self.driver_auto_json = ['loads'] + else: + LOGGER.debug("Your database version does not support the JSON" + " data type (using TEXT instead)") def LIKE(self, first, second): args = (self.expand(first), self.expand(second, 'string'))