From b10378fe708893df1b218b16e004f07450d03189 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 17 Sep 2019 11:01:13 +0530 Subject: [PATCH] Fix query history issue for Python 2.7, it is a regression of #4750. --- web/pgadmin/tools/sqleditor/utils/query_history.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/pgadmin/tools/sqleditor/utils/query_history.py b/web/pgadmin/tools/sqleditor/utils/query_history.py index 84faaa8a4..a2baebcdf 100644 --- a/web/pgadmin/tools/sqleditor/utils/query_history.py +++ b/web/pgadmin/tools/sqleditor/utils/query_history.py @@ -1,6 +1,7 @@ from pgadmin.utils.ajax import make_json_response from pgadmin.model import db, QueryHistoryModel from config import MAX_QUERY_HIST_STORED +from pgadmin.utils import IS_PY2 class QueryHistory: @@ -15,14 +16,14 @@ class QueryHistory: .all() # In Python 2.7, rec.query_info has buffer data type. Cast it. + if IS_PY2: + result = [bytes(rec.query_info) for rec in list(result)] + return make_json_response( data={ 'status': True, 'msg': '', - 'result': [ - bytes(rec.query_info, encoding='utf8') - for rec in list(result) - ] + 'result': result } )