Subject: [pgAdmin][Patch]: Fixed RM #3362 - Database restore utility does not honour restore options for sections

From: Khushboo Vashi <[email-masked]>
Date: Mon, 2 Jul 2018 10:39:16 +0530

Hi,

Please find the attached patch to fix RM #3362 : Database restore utility
does not honour restore options for sections.

Thanks,
Khushboo
diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py
index 1e54985..81e480a 100644
--- a/web/pgadmin/tools/restore/__init__.py
+++ b/web/pgadmin/tools/restore/__init__.py
@@ -299,13 +299,13 @@ def create_restore_job(sid):
         if data['format'] == 'directory':
             args.extend(['--format=d'])
 
-        set_value('pre_data', '--section=pre-data', False)
-        set_value('data', '--section=data', False)
-        set_value('post_data', '--section=post-data', False)
+        set_param('pre_data', '--section=pre-data')
+        set_param('data', '--section=data')
+        set_param('post_data', '--section=post-data')
 
         if not set_param('only_data', '--data-only'):
             set_param('dns_owner', '--no-owner')
-            set_param('dns_privilege ', '--no-privileges')
+            set_param('dns_privilege', '--no-privileges')
             set_param('dns_tablespace', '--no-tablespaces')
 
         if not set_param('only_schema', '--schema-only'):
@@ -314,8 +314,8 @@ def create_restore_job(sid):
         set_param('include_create_database', '--create')
         set_param('clean', '--clean')
         set_param('single_transaction', '--single-transaction')
-        set_param('no_data_fail_table ', '--no-data-for-failed-tables')
-        set_param('use_set_session_auth ', '--use-set-session-authorization')
+        set_param('no_data_fail_table', '--no-data-for-failed-tables')
+        set_param('use_set_session_auth', '--use-set-session-authorization')
         set_param('exit_on_error', '--exit-on-error')
 
         set_value('no_of_jobs', '--jobs', True)
diff --git a/web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py b/web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py
index 223d516..23a1cf0 100644
--- a/web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py
+++ b/web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py
@@ -104,8 +104,9 @@ class RestoreCreateJobTest(BaseTestGenerator):
                  only_schema=True
              ),
              url='/restore/job/{0}',
-             # Please include sections data here, right now this is a bug
-             expected_cmd_opts=['--verbose', '--jobs', '2'],
+             expected_cmd_opts=['--verbose', '--jobs', '2',
+                                '--section=pre-data', '--section=data',
+                                '--section=post-data'],
              not_expected_cmd_opts=[],
              # Below options should be enabled once we fix the issue #3368
              # not_expected_cmd_opts=['--data-only', '--schema-only'],
@@ -167,9 +168,9 @@ class RestoreCreateJobTest(BaseTestGenerator):
                  only_data=False
              ),
              url='/restore/job/{0}',
-             # Add '--no-privileges' to the expected_cmd once #3363 fixed
              expected_cmd_opts=['--no-owner',
-                                '--no-tablespaces'],
+                                '--no-tablespaces',
+                                '--no-privileges'],
              not_expected_cmd_opts=[],
              expected_exit_code=[0, None]
          )),
@@ -224,9 +225,8 @@ class RestoreCreateJobTest(BaseTestGenerator):
                  only_schema=False
              ),
              url='/restore/job/{0}',
-             # Add '--no-data-for-failed-tables' into
-             # expected_cmd_opts once #3363 fixed
-             expected_cmd_opts=['--disable-triggers'],
+             expected_cmd_opts=['--disable-triggers',
+                                '--no-data-for-failed-tables'],
              not_expected_cmd_opts=[],
              expected_exit_code=[0, None]
          )),

---

From: Dave Page <[email-masked]>
Date: Mon, 2 Jul 2018 15:56:09 +0100

Thanks, applied.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company