Fix an issue where connection string sequences do not persist after updating server details. #7041

This commit is contained in:
Nikhil Mohite 2024-01-01 14:11:17 +05:30 committed by GitHub
parent 2b736c18ab
commit 2621050066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@
########################################################################## ##########################################################################
import json import json
from collections import OrderedDict
import pgadmin.browser.server_groups as sg import pgadmin.browser.server_groups as sg
from flask import render_template, request, make_response, jsonify, \ from flask import render_template, request, make_response, jsonify, \
current_app, url_for, session current_app, url_for, session
@ -1131,13 +1132,21 @@ class ServerNode(PGChildNodeView):
def update_connection_string(manager, server): def update_connection_string(manager, server):
# Get current connection info in dict. # Get current connection info in dict.
con_info = conninfo_to_dict(manager.display_connection_string) con_info = conninfo_to_dict(manager.display_connection_string)
db_name = con_info['dbname'] if 'dbname' in con_info else None
# Update host, port and user if 'host' in con_info and 'port' in con_info and 'user' in con_info:
con_info['host'] = server.host con_info.pop('host')
con_info['port'] = server.port con_info.pop('port')
con_info['user'] = server.username con_info.pop('user')
display_conn_string = make_conninfo(**con_info) # Create ordered dict to maintain the order of updated host, port,
# dbname, user.
con_info_ord = OrderedDict([('host', server.host),
('port', server.port),
('dbname', db_name),
('user', server.username)])
con_info_ord.update(con_info)
display_conn_string = make_conninfo(**con_info_ord)
return display_conn_string return display_conn_string
@login_required @login_required