diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/create.sql index 6abb15cd2..0ada5f897 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/create.sql @@ -13,7 +13,7 @@ add empty bracket with table name #} {% set empty_bracket = ""%} -{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %} +{% if not (data.coll_inherits or data.columns or data.typname or data.like_relation or data.primary_key or data.unique_constraint or data.foreign_key or data.check_constraint or data.exclude_constraint) %} {% set empty_bracket = "\n(\n)"%} {% endif %} {% set with_clause = false%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/17_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/17_plus/test.json index 11cc62f0f..56b016f23 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/17_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/17_plus/test.json @@ -34,6 +34,7 @@ "endpoint": "NODE-publication.obj", "sql_endpoint": "NODE-publication.sql_id", "msql_endpoint": "NODE-publication.msql", + "precondition_sql": "SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription' UNION ALL SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') AND pg_create_logical_replication_slot('test_create_subscription', 'pgoutput', false) IS NOT NULL LIMIT 1;", "data": { "name": "test_publication", "evnt_insert": true, @@ -116,7 +117,8 @@ "endpoint": "NODE-subscription.delete_id", "data": { "name": "test_create_subscription" - } + }, + "post_scenario_sql": "SELECT 1 WHERE EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') AND (SELECT pg_drop_replication_slot('test_create_subscription')) IS NOT NULL UNION ALL SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') LIMIT 1;" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/18_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/18_plus/test.json index 9e893ebd7..f1a34c88d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/18_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/18_plus/test.json @@ -6,6 +6,7 @@ "endpoint": "NODE-subscription.obj", "sql_endpoint": "NODE-subscription.sql_id", "msql_endpoint": "NODE-subscription.msql", + "precondition_sql": "SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription' UNION ALL SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') AND pg_create_logical_replication_slot('test_create_subscription', 'pgoutput', false) IS NOT NULL LIMIT 1;", "data": { "name": "test_create_subscription", "subowner": "postgres", @@ -66,7 +67,8 @@ "endpoint": "NODE-subscription.delete_id", "data": { "name": "test_create_subscription" - } + }, + "post_scenario_sql": "SELECT 1 WHERE EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') AND (SELECT pg_drop_replication_slot('test_create_subscription')) IS NOT NULL UNION ALL SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_create_subscription') LIMIT 1;" } ] } diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py index ba7cd5cd0..1730b6135 100644 --- a/web/regression/re_sql/tests/test_resql.py +++ b/web/regression/re_sql/tests/test_resql.py @@ -95,35 +95,6 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): # Added line break after scenario name print("") - # Create replication slot if it does not exist for the - # RESQL test-cases of Subscriptions for PGv17 and above - if self.server_information['server_version'] >= 170000: - try: - self.get_db_connection() - pg_cursor = self.connection.cursor() - pg_cursor.execute(""" - SELECT 1 FROM pg_replication_slots - WHERE slot_name = 'test_create_subscription' - """) - exists = pg_cursor.fetchone() - if not exists: - pg_cursor.execute(""" - SELECT pg_create_logical_replication_slot( - 'test_create_subscription', - 'pgoutput', - failover := false - ); - """) - self.connection.commit() - print("Replication slot " - "'test_create_subscription' created.") - else: - print("Replication slot 'test_create_subscription' " - "already exists.") - pg_cursor.close() - except Exception as e: - print("Could not create replication slot: ", e) - def runTest(self): """ Create the module list on which reverse engineeredsql test cases will be executed.""" @@ -182,30 +153,6 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): # Check the final status of the test case self.assertEqual(self.final_test_status, True) - def tearDown(self): - # Drop the replication slot created for the RESQL test-cases of - # Subscriptions, if it exists before disconnecting for PGv17 and above - if self.server_information['server_version'] >= 170000: - try: - self.get_db_connection() - pg_cursor = self.connection.cursor() - pg_cursor.execute(""" - SELECT 1 FROM pg_replication_slots - WHERE slot_name = 'test_create_subscription' - """) - exists = pg_cursor.fetchone() - if exists: - pg_cursor.execute(""" - SELECT - pg_drop_replication_slot('test_create_subscription'); - """) - self.connection.commit() - print("Replication slot " - "'test_create_subscription' dropped.") - pg_cursor.close() - except Exception as e: - print("Could not drop replication slot: ", e) - database_utils.disconnect_database( self, self.server_information['server_id'], self.server_information['db_id']) @@ -653,7 +600,10 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): try: pg_cursor.execute(precondition_sql) precondition_result = pg_cursor.fetchone() - if len(precondition_result) >= 1 and precondition_result[0] == '1': + if ((len(precondition_result) >= 1 and + precondition_result[0] == '1') or + (isinstance(precondition_result, tuple) and + precondition_result[0] == 1)): precondition_flag = True except Exception as e: traceback.print_exc()