From 37278f2cd32bb16dddbfe9926c143b53f8efa8d0 Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Thu, 17 Jun 2021 16:22:53 +0530 Subject: [PATCH] Fixed API test cases for PG/EPAS 9.6 --- .../tables/constraints/check_constraint/__init__.py | 10 +++++++--- .../tests/check_constraint_test_data.json | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py index 2692bc026..161bc9e0e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py @@ -228,8 +228,7 @@ class CheckConstraintView(PGChildNodeView): Returns: """ - SQL = "END;" - self.conn.execute_scalar(SQL) + self.conn.execute_void("END;") @check_precondition def list(self, gid, sid, did, scid, tid, cid=None): @@ -536,8 +535,9 @@ class CheckConstraintView(PGChildNodeView): if 'name' not in data or data['name'] == "": sql = "BEGIN;" # Start transaction. - status, res = self.conn.execute_scalar(sql) + status, res = self.conn.execute_void(sql) if not status: + self.conn.execute_void('ROLLBACK;') self.end_transaction() return internal_server_error(errormsg=res) @@ -549,6 +549,7 @@ class CheckConstraintView(PGChildNodeView): status, msg = self.conn.execute_scalar(sql) if not status: + self.conn.execute_void('ROLLBACK;') self.end_transaction() return internal_server_error(errormsg=msg) @@ -561,6 +562,7 @@ class CheckConstraintView(PGChildNodeView): status, res = self.conn.execute_dict(sql) if not status: + self.conn.execute_void('ROLLBACK;') self.end_transaction() return internal_server_error(errormsg=res) @@ -576,6 +578,7 @@ class CheckConstraintView(PGChildNodeView): ) status, res = self.conn.execute_dict(sql) if not status: + self.conn.execute_void('ROLLBACK;') self.end_transaction() return internal_server_error(errormsg=res) @@ -592,6 +595,7 @@ class CheckConstraintView(PGChildNodeView): ) except Exception as e: + self.conn.execute_void('ROLLBACK;') self.end_transaction() return make_json_response( status=400, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json index 28debaf33..5f8dd7f5f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json @@ -469,7 +469,7 @@ }, "mocking_required": true, "mock_data": { - "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar", + "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_void", "return_value": "(False,'Mocked Internal Server Error')" }, "expected_data": { @@ -547,7 +547,7 @@ "test_data": {}, "mocking_required": true, "mock_data": { - "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar", + "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_void", "return_value": "(False,'Mocked Internal Server Error')" }, "expected_data": {