-
Notifications
You must be signed in to change notification settings - Fork 810
Fixed an issue when the server/database connection was lost; the filter dialog is not getting saved. #6044 #8360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
web/pgadmin/tools/sqleditor/utils/query_tool_connection_check.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ########################################################################## | ||
| # | ||
| # pgAdmin 4 - PostgreSQL Tools | ||
| # | ||
| # Copyright (C) 2013 - 2025, The pgAdmin Development Team | ||
| # This software is released under the PostgreSQL Licence | ||
| # | ||
| ########################################################################## | ||
|
|
||
| """Check for query tool connection""" | ||
| import pickle | ||
| from flask_babel import gettext | ||
|
|
||
| from config import PG_DEFAULT_DRIVER | ||
| from pgadmin.utils.ajax import internal_server_error | ||
| from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry | ||
| from pgadmin.tools.sqleditor.utils.start_running_query import StartRunningQuery | ||
| from flask import Response, current_app, session | ||
|
|
||
| from pgadmin.utils.driver import get_driver | ||
|
|
||
|
|
||
| def query_tool_connection_check(trans_id): | ||
| # This function will check if the query tool has the connection or not | ||
| # if not then establishes the connection. | ||
| session_obj = StartRunningQuery.retrieve_session_information( | ||
| session, | ||
| trans_id | ||
| ) | ||
| if isinstance(session_obj, Response): | ||
| return session_obj | ||
|
|
||
| transaction_object = pickle.loads(session_obj['command_obj']) | ||
|
|
||
| # To verify if the transaction details for the specific query tool | ||
| # or View/Edit Data tool is available or not and if the server is | ||
| # disconnected from the Object Explorer then it reconnects | ||
| if transaction_object is not None and session_obj is not None: | ||
| view = SchemaDiffRegistry.get_node_view('server') | ||
| response = view.connect(transaction_object.sgid, | ||
| transaction_object.sid, True) | ||
| # This is required for asking user to enter password | ||
| # when password is not saved for the server | ||
| if response.status_code == 428: | ||
| return False, None, None, None, None, response | ||
| else: | ||
| manager = get_driver( | ||
| PG_DEFAULT_DRIVER).connection_manager( | ||
| transaction_object.sid) | ||
| conn = manager.connection( | ||
| did=transaction_object.did, | ||
| conn_id=transaction_object.conn_id, | ||
| auto_reconnect=False, | ||
| use_binary_placeholder=True, | ||
| array_to_string=True, | ||
| **({"database": transaction_object.dbname} if hasattr( | ||
| transaction_object, 'dbname') else {})) | ||
|
|
||
| status, msg = conn.connect() | ||
| if not status: | ||
| current_app.logger.error(msg) | ||
| return internal_server_error(errormsg=str(msg)) | ||
| return status, None, conn, transaction_object, session_obj, None | ||
| else: | ||
| status = False | ||
| error_msg = gettext( | ||
| 'Either transaction object or session object not found.') | ||
| return status, error_msg, None, None, None, None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.