Make the Query Tool history persistent across sessions. Fixes #4017

This commit is contained in:
Dave Page
2019-03-13 13:37:34 +00:00
parent a502019e20
commit ab9a3a57ad
16 changed files with 581 additions and 66 deletions

View File

@@ -20,6 +20,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request, forbidden, \
make_response as ajax_response, internal_server_error, unauthorized, gone
from pgadmin.utils.crypto import encrypt, decrypt, pqencryptpassword
from pgadmin.utils.menu import MenuItem
from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
import config
from config import PG_DEFAULT_DRIVER
@@ -450,6 +451,9 @@ class ServerNode(PGChildNodeView):
get_driver(PG_DEFAULT_DRIVER).delete_manager(s.id)
db.session.delete(s)
db.session.commit()
QueryHistory.clear_history(current_user.id, sid)
except Exception as e:
current_app.logger.exception(e)
return make_json_response(

View File

@@ -15,6 +15,7 @@ from functools import wraps
import simplejson as json
from flask import render_template, current_app, request, jsonify
from flask_babelex import gettext as _
from flask_security import current_user
import pgadmin.browser.server_groups.servers as servers
from config import PG_DEFAULT_DRIVER
@@ -28,6 +29,7 @@ from pgadmin.utils.ajax import gone
from pgadmin.utils.ajax import make_json_response, \
make_response as ajax_response, internal_server_error, unauthorized
from pgadmin.utils.driver import get_driver
from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
class DatabaseModule(CollectionNodeModule):
@@ -675,6 +677,8 @@ class DatabaseView(PGChildNodeView):
)
return internal_server_error(errormsg=msg)
QueryHistory.update_history_dbname(
current_user.id, sid, data['old_name'], data['name'])
# Make connection for database again
if self._db['datallowconn']:
self.conn = self.manager.connection(