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 } )