Skip to content

Commit

Permalink
Fix an issue where connection string sequences do not persist after u…
Browse files Browse the repository at this point in the history
…pdating server details. pgadmin-org#7041
  • Loading branch information
nikhil-mohite committed Jan 1, 2024
1 parent ec12dc5 commit edb74e9
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions web/pgadmin/browser/server_groups/servers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
##########################################################################

import json
from collections import OrderedDict
import pgadmin.browser.server_groups as sg
from flask import render_template, request, make_response, jsonify, \
current_app, url_for, session
Expand Down Expand Up @@ -1131,13 +1132,21 @@ def properties(self, gid, sid):
def update_connection_string(manager, server):
# Get current connection info in dict.
con_info = conninfo_to_dict(manager.display_connection_string)

# Update host, port and user
con_info['host'] = server.host
con_info['port'] = server.port
con_info['user'] = server.username

display_conn_string = make_conninfo(**con_info)
db_name = con_info['dbname'] if 'dbname' in con_info else None

if 'host' in con_info and 'port' in con_info and 'user' in con_info:
con_info.pop('host')
con_info.pop('port')
con_info.pop('user')

# 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

@login_required
Expand Down

0 comments on commit edb74e9

Please sign in to comment.