From b5c299c5ad2547c2813dfb78c6e9fbfb0c382e9a Mon Sep 17 00:00:00 2001 From: Rahul Shirsat Date: Mon, 31 Aug 2020 17:49:46 +0530 Subject: [PATCH] Fixed an issue where --load-server does not allow loading connections that use pg_services. Fixes #5746 --- docs/en_US/release_notes_4_26.rst | 1 + web/setup.py | 39 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/docs/en_US/release_notes_4_26.rst b/docs/en_US/release_notes_4_26.rst index 617dd4949..c6cd3c2f3 100644 --- a/docs/en_US/release_notes_4_26.rst +++ b/docs/en_US/release_notes_4_26.rst @@ -26,6 +26,7 @@ Bug fixes | `Issue #5426 `_ - Adjusted the height of jobstep code block to use maximum space. | `Issue #5652 `_ - Modified the 'Commit' and 'Rollback' query tool button icons. | `Issue #5722 `_ - Ensure that the user should be able to drop the database even if it is connected. +| `Issue #5746 `_ - Fixed an issue where --load-server does not allow loading connections that use pg_services. | `Issue #5748 `_ - Fixed incorrect reverse engineering SQL for Foreign key when creating a table. | `Issue #5751 `_ - Enable the 'Configure' and 'View log' menu option when the server taking longer than usual time to start. | `Issue #5754 `_ - Fixed an issue where schema diff is not working when providing the options to Foreign Data Wrapper, Foreign Server, and User Mapping. diff --git a/web/setup.py b/web/setup.py index 9a78f1b59..c88c4e1fa 100644 --- a/web/setup.py +++ b/web/setup.py @@ -231,18 +231,22 @@ def load_servers(args): check_attrib("Name") check_attrib("Group") - check_attrib("Port") - check_attrib("Username") + + is_service_attrib_available = True if "Service" in obj else False + + if not is_service_attrib_available: + check_attrib("Port") + check_attrib("Username") + check_attrib("SSLMode") check_attrib("MaintenanceDB") - if "Host" not in obj and \ - "HostAddr" not in obj and \ - "Service" not in obj: - print("'Host', 'HostAddr' or 'Service' attribute not found " - "for server '%s'" % server) - print_summary() - sys.exit(1) + if "Host" not in obj and "HostAddr" not in obj: + if is_service_attrib_available is False: + print("'Host', 'HostAddr' or 'Service' attribute " + "not found for server '%s'" % server) + print_summary() + sys.exit(1) # Get the group. Create if necessary group_id = -1 @@ -274,21 +278,24 @@ def load_servers(args): new_server.name = obj["Name"] new_server.servergroup_id = group_id new_server.user_id = user_id + new_server.ssl_mode = obj["SSLMode"] + new_server.maintenance_db = obj["MaintenanceDB"] - new_server.host = obj["Host"] + if "Host" in obj: + new_server.host = obj["Host"] if "HostAddr" in obj: new_server.hostaddr = obj["HostAddr"] - new_server.port = obj["Port"] - new_server.maintenance_db = obj["MaintenanceDB"] - new_server.username = obj["Username"] + if "Port" in obj: + new_server.port = obj["Port"] + + if "Username" in obj: + new_server.username = obj["Username"] if "Role" in obj: new_server.role = obj["Role"] - new_server.ssl_mode = obj["SSLMode"] - if "Comment" in obj: new_server.comment = obj["Comment"] @@ -319,7 +326,7 @@ def load_servers(args): if "FGColor" in obj: new_server.fgcolor = obj["FGColor"] - if "Service" in obj: + if is_service_attrib_available: new_server.service = obj["Service"] if "Timeout" in obj: