diff --git a/docs/en_US/backup_dialog.rst b/docs/en_US/backup_dialog.rst index e3bc0d44a..3091f13c1 100644 --- a/docs/en_US/backup_dialog.rst +++ b/docs/en_US/backup_dialog.rst @@ -200,31 +200,29 @@ tab related to tables that should be included in the backup. contents of the table that they have access to. This option is relevant only when dumping the contents of a table which has row security. - * Move the switch next to *With OIDs* towards right position to include object - identifiers as part of the table data for each table. - - * Use the *Table and Children* field to dump the tables and any partitions - or inheritance child tables of the tables matching the table pattern. Multiple patterns - can be given separated by space. **Note:** This option is visible only - for database server greater than or equal to 16. - - * Use the *Exclude table* field to not dump the tables matching the table - pattern. Multiple patterns can be given separated by space. - - * Use the *Exclude table data* field to not dump data for any tables - matching the table pattern. Multiple patterns can be given separated by - spaces. - - * Use the *Exclude table and children* field to not dump the tables and any - partitions or inheritance child tables of the tables matching the table - pattern. Multiple patterns can be given separated by space. **Note:** This - option is visible only for database server greater than or equal to 16. - - * Use the *Exclude table data and children* field to not dump data for the - tables and any partitions or inheritance child tables of the tables matching - the table pattern. Multiple patterns can be given separated by space. + * Use the *Include table(s) and Children* field to dump the tables and any partitions + or inheritance child tables of the tables matching the pattern. **Note:** This option is visible only for database server greater than or equal to 16. + + * The Exclude patterns field is utilized to exclude patterns in the following manner: + + * Use the *Table(s)* field to not dump the tables matching the + pattern. Multiple patterns can be given separated by space. + + * Use the *Table(s) data* field to not dump data for any tables + matching the pattern. Multiple patterns can be given separated by + spaces. + + * Use the *Table(s) and children* field to not dump the tables and any + partitions or inheritance child tables of the tables matching the pattern. + **Note:** This option is visible only for database server greater than or + equal to 16. + + * Use the *Table(s) data and children* field to not dump data for the + tables and any partitions or inheritance child tables of the tables matching + the table pattern. **Note:** This option is visible only for database server + greater than or equal to 16. Click the *Options* tab to continue. Use the fields in the *Options* tab to provide other backup options. diff --git a/docs/en_US/backup_server_dialog.rst b/docs/en_US/backup_server_dialog.rst index b9685c659..47823fdcf 100644 --- a/docs/en_US/backup_server_dialog.rst +++ b/docs/en_US/backup_server_dialog.rst @@ -136,9 +136,6 @@ tab related to tables that should be included in the backup. partition itself. **Note:** This option is visible only for database server greater than or equal to 11. - * Move the switch next to *With OIDs* towards right position to include object - identifiers as part of the table data for each table. - Click the *Options* tab to continue. Use the fields in the *Options* tab to provide other backup options. diff --git a/docs/en_US/images/backup_server_table.png b/docs/en_US/images/backup_server_table.png index e5387075a..a24356f17 100644 Binary files a/docs/en_US/images/backup_server_table.png and b/docs/en_US/images/backup_server_table.png differ diff --git a/docs/en_US/images/backup_table.png b/docs/en_US/images/backup_table.png index 2e5a717de..1dde76ab2 100644 Binary files a/docs/en_US/images/backup_table.png and b/docs/en_US/images/backup_table.png differ diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index c651cd29c..2020cb16d 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -236,10 +236,13 @@ def _get_args_params_values(data, conn, backup_obj_type, backup_file, server, return val = data.get(key, default_value) if val: - val = val.split() - for c_val in val: - args.append(param) - args.append(c_val) + if isinstance(val, list): + for c_val in val: + args.append(param) + args.append(c_val) + return + args.append(param) + args.append(val) if backup_obj_type != 'objects': args.append('--database') @@ -317,7 +320,6 @@ def _get_args_params_values(data, conn, backup_obj_type, backup_file, server, set_param('use_column_inserts', '--column-inserts') set_param('load_via_partition_root', '--load-via-partition-root', manager.version >= 110000) - set_param('with_oids', '--oids') set_param('enable_row_security', '--enable-row-security') set_value('exclude_table_data', '--exclude-table-data') set_value('table_and_children', '--table-and-children', None, diff --git a/web/pgadmin/tools/backup/static/js/backup.js b/web/pgadmin/tools/backup/static/js/backup.js index 87eeec5ec..38180a350 100644 --- a/web/pgadmin/tools/backup/static/js/backup.js +++ b/web/pgadmin/tools/backup/static/js/backup.js @@ -7,7 +7,7 @@ // ////////////////////////////////////////////////////////////// import { getNodeListByName, getNodeAjaxOptions } from '../../../../browser/static/js/node_ajax'; -import BackupSchema, {getSectionSchema, getTypeObjSchema, getSaveOptSchema, getDisabledOptionSchema, getMiscellaneousSchema} from './backup.ui'; +import BackupSchema, {getSectionSchema, getTypeObjSchema, getSaveOptSchema, getDisabledOptionSchema, getMiscellaneousSchema, getExcludePatternsSchema} from './backup.ui'; import BackupGlobalSchema, {getMiscellaneousSchema as getMiscellaneousGlobalSchema} from './backupGlobal.ui'; import getApiInstance from 'sources/api_instance'; import {retrieveAncestorOfTypeServer} from 'sources/tree/tree_utils'; @@ -244,6 +244,7 @@ define([ ()=> getSaveOptSchema({nodeInfo: treeNodeInfo}), ()=> getDisabledOptionSchema({nodeInfo: treeNodeInfo}), ()=> getMiscellaneousSchema({nodeInfo: treeNodeInfo}), + ()=> getExcludePatternsSchema(), { role: ()=>getNodeListByName('role', treeNodeInfo, itemNodeData), encoding: ()=>getNodeAjaxOptions('get_encodings', pgBrowser.Nodes['database'], treeNodeInfo, itemNodeData, { diff --git a/web/pgadmin/tools/backup/static/js/backup.ui.js b/web/pgadmin/tools/backup/static/js/backup.ui.js index 72a53ec7b..6cd4569d4 100644 --- a/web/pgadmin/tools/backup/static/js/backup.ui.js +++ b/web/pgadmin/tools/backup/static/js/backup.ui.js @@ -382,18 +382,20 @@ export class MiscellaneousSchema extends BaseUISchema { }, { id: 'exclude_schema', label: gettext('Exclude schema'), - type: 'text', + type: 'select', disabled: false, group: gettext('Miscellaneous'), - visible: isVisibleForServerBackup(obj?._top?.backupType) + visible: isVisibleForServerBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } }, { id: 'exclude_database', label: gettext('Exclude database'), - type: 'text', + type: 'select', disabled: false, min_version: 160000, group: gettext('Miscellaneous'), - visible: isVisibleForObjectBackup(obj?._top?.backupType) + visible: isVisibleForObjectBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } }, { id: 'extra_float_digits', label: gettext('Extra float digits'), @@ -415,8 +417,67 @@ export function getMiscellaneousSchema(fieldOptions) { return new MiscellaneousSchema(fieldOptions); } +export class ExcludePatternsSchema extends BaseUISchema { + constructor(fieldOptions={}, initValues={}) { + super({ + ...initValues, + }); + + this.fieldOptions = { + ...fieldOptions, + }; + } + + get idAttribute() { + return 'id'; + } + + get baseFields() { + let obj = this; + return [{ + id: 'exclude_table', + label: gettext('Table(s)'), + type: 'select', + disabled: false, + group: gettext('Table Options'), + visible: isVisibleForServerBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } + }, { + id: 'exclude_table_data', + label: gettext('Table(s) data'), + type: 'select', + disabled: false, + group: gettext('Table Options'), + visible: isVisibleForServerBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } + }, { + id: 'exclude_table_and_children', + label: gettext('Table(s) and children'), + type: 'select', + disabled: false, + group: gettext('Table Options'), + min_version: 160000, + visible: isVisibleForServerBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } + }, { + id: 'exclude_table_data_and_children', + label: gettext('Table(s) data and children'), + type: 'select', + disabled: false, + group: gettext('Table Options'), + min_version: 160000, + visible: isVisibleForServerBackup(obj?._top?.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } + }]; + } +} + +export function getExcludePatternsSchema() { + return new ExcludePatternsSchema(); +} + export default class BackupSchema extends BaseUISchema { - constructor(sectionSchema, typeObjSchema, saveOptSchema, disabledOptionSchema, miscellaneousSchema, fieldOptions = {}, treeNodeInfo=[], pgBrowser=null, backupType='server', objects={}) { + constructor(sectionSchema, typeObjSchema, saveOptSchema, disabledOptionSchema, miscellaneousSchema, excludePatternsSchema, fieldOptions = {}, treeNodeInfo=[], pgBrowser=null, backupType='server', objects={}) { super({ file: undefined, format: 'custom', @@ -439,6 +500,7 @@ export default class BackupSchema extends BaseUISchema { this.getSaveOptSchema = saveOptSchema; this.getDisabledOptionSchema = disabledOptionSchema; this.getMiscellaneousSchema = miscellaneousSchema; + this.getExcludePatternsSchema = excludePatternsSchema; } get idAttribute() { @@ -640,62 +702,21 @@ export default class BackupSchema extends BaseUISchema { }, visible: isVisibleForServerBackup(obj.backupType), helpMessage: gettext('This option is enabled only when Use INSERT Commands is enabled.') - }, { - id: 'with_oids', - label: gettext('With OID(s)'), - type: 'switch', - deps: ['use_column_inserts', 'use_insert_commands'], - group: gettext('Table Options'), - disabled: function(state) { - let serverInfo = _.isUndefined(obj.treeNodeInfo) ? undefined : obj.treeNodeInfo.server; - - if (!_.isUndefined(serverInfo) && serverInfo.version >= 120000) - return true; - - if (state.use_column_inserts || state.use_insert_commands) { - state.with_oids = false; - return true; - } - return false; - }, }, { id: 'table_and_children', - label: gettext('Table and Children'), - type: 'text', + label: gettext('Include table(s) and Children'), + type: 'select', disabled: false, group: gettext('Table Options'), min_version: 160000, - visible: isVisibleForServerBackup(obj.backupType) + visible: isVisibleForServerBackup(obj.backupType), + controlProps: { multiple: true, allowClear: false, creatable: true, noDropdown: true, placeholder: ' ' } }, { - id: 'exclude_table', - label: gettext('Exclude table'), - type: 'text', - disabled: false, + type: 'nested-fieldset', + label: gettext('Exclude patterns'), group: gettext('Table Options'), - visible: isVisibleForServerBackup(obj.backupType) - }, { - id: 'exclude_table_data', - label: gettext('Exclude table data'), - type: 'text', - disabled: false, - group: gettext('Table Options'), - visible: isVisibleForServerBackup(obj.backupType) - }, { - id: 'exclude_table_and_children', - label: gettext('Exclude table and children'), - type: 'text', - disabled: false, - group: gettext('Table Options'), - min_version: 160000, - visible: isVisibleForServerBackup(obj.backupType) - }, { - id: 'exclude_table_data_and_children', - label: gettext('Exclude table data and children'), - type: 'text', - disabled: false, - group: gettext('Table Options'), - min_version: 160000, - visible: isVisibleForServerBackup(obj.backupType) + schema: obj.getExcludePatternsSchema(), + visible: isVisibleForServerBackup(obj.backupType), }, { type: 'nested-fieldset', label: gettext('Disable'), diff --git a/web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py b/web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py index 8197942ad..1095f390c 100644 --- a/web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py +++ b/web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py @@ -500,7 +500,7 @@ class BackupCreateJobTest(BaseTestGenerator): schemas=[], tables=[], database='postgres', - exclude_table_data='table1', + exclude_table_data=['table1'], ), url=BACKUP_OBJECT_URL, expected_cmd_opts=['--exclude-table-data', 'table1'], @@ -560,12 +560,11 @@ class BackupCreateJobTest(BaseTestGenerator): database='postgres', disable_quoting=True, use_set_session_auth=True, - with_oids=True, dqoute=True ), url=BACKUP_OBJECT_URL, expected_cmd_opts=[VERBOSE, '--quote-all-identifiers', - '--disable-dollar-quoting', '--oids', + '--disable-dollar-quoting', '--use-set-session-authorization'], not_expected_cmd_opts=[], expected_exit_code=[0, None] @@ -588,7 +587,7 @@ class BackupCreateJobTest(BaseTestGenerator): schemas=[], tables=[], database='postgres', - exclude_schema="sch*" + exclude_schema=["sch*"] ), url=BACKUP_OBJECT_URL, expected_cmd_opts=[VERBOSE, '--exclude-schema', 'sch*'], @@ -726,7 +725,7 @@ class BackupCreateJobTest(BaseTestGenerator): schemas=[], tables=[], database='postgres', - exclude_table="table1" + exclude_table=["table1"] ), url=BACKUP_OBJECT_URL, expected_cmd_opts=['--exclude-table', 'table1'], @@ -1174,12 +1173,11 @@ class BackupCreateJobTest(BaseTestGenerator): verbose=True, disable_quoting=True, use_set_session_auth=True, - with_oids=True, dqoute=True ), url=BACKUP_SERVER_URL, expected_cmd_opts=[VERBOSE, '--quote-all-identifiers', - '--disable-dollar-quoting', '--oids', + '--disable-dollar-quoting', '--use-set-session-authorization'], not_expected_cmd_opts=[], expected_exit_code=[0, None] diff --git a/web/regression/javascript/schema_ui_files/backup.ui.spec.js b/web/regression/javascript/schema_ui_files/backup.ui.spec.js index 3b8c3d808..6bd3c2fad 100644 --- a/web/regression/javascript/schema_ui_files/backup.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/backup.ui.spec.js @@ -11,7 +11,7 @@ import React from 'react'; import pgAdmin from 'sources/pgadmin'; import SchemaView from '../../../pgadmin/static/js/SchemaView'; -import BackupSchema, {getSectionSchema, getTypeObjSchema, getSaveOptSchema, getDisabledOptionSchema, getMiscellaneousSchema} from '../../../pgadmin/tools/backup/static/js/backup.ui'; +import BackupSchema, {getSectionSchema, getTypeObjSchema, getSaveOptSchema, getDisabledOptionSchema, getMiscellaneousSchema, getExcludePatternsSchema} from '../../../pgadmin/tools/backup/static/js/backup.ui'; import { getCreateView, withBrowser } from '../genericFunctions'; import { act, render } from '@testing-library/react'; @@ -23,6 +23,7 @@ describe('BackupSchema', ()=>{ ()=> getSaveOptSchema({nodeInfo: {server: {version: 11000}}}), ()=> getDisabledOptionSchema({nodeInfo: {server: {version: 11000}}}), ()=> getMiscellaneousSchema({nodeInfo: {server: {version: 11000}}}), + ()=> getExcludePatternsSchema(), { role: ()=>[], encoding: ()=>[], @@ -44,6 +45,7 @@ describe('BackupSchema', ()=>{ ()=> getSaveOptSchema({nodeInfo: {server: {version: 11000}}}), ()=> getDisabledOptionSchema({nodeInfo: {server: {version: 11000}}}), ()=> getMiscellaneousSchema({nodeInfo: {server: {version: 11000}}}), + ()=> getExcludePatternsSchema(), { role: ()=>[], encoding: ()=>[], @@ -83,6 +85,7 @@ describe('BackupSchema', ()=>{ ()=> getSaveOptSchema({nodeInfo: {server: {version: 11000}}}), ()=> getDisabledOptionSchema({nodeInfo: {server: {version: 11000}}}), ()=> getMiscellaneousSchema({nodeInfo: {server: {version: 11000}}}), + ()=> getExcludePatternsSchema(), { role: ()=>[], encoding: ()=>[],