Fixed issue found during testing of #7163.

This commit is contained in:
Pravesh Sharma
2024-04-29 13:12:21 +05:30
committed by GitHub
parent 7c6fdcb12e
commit e18a8bf620
9 changed files with 114 additions and 94 deletions

View File

@@ -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,

View File

@@ -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, {

View File

@@ -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'),

View File

@@ -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]