mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Foreign key issues in edit mode:
1. Couple of foreign key issues in edit mode. Fixes #6837 2. Table "Of type" related issues. Fixes #6825
This commit is contained in:
parent
69109a19db
commit
e77f933fe7
@ -22,7 +22,7 @@ export default class CheckConstraintSchema extends BaseUISchema {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['table']);
|
||||
return _.isUndefined(this.nodeInfo['check_constraint']);
|
||||
}
|
||||
|
||||
isReadonly(state) {
|
||||
|
@ -213,7 +213,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['table']);
|
||||
return _.isUndefined(this.nodeInfo['exclusion_constraint']);
|
||||
}
|
||||
|
||||
initialise(data) {
|
||||
|
@ -149,7 +149,7 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
if(_.isUndefined(nodeInfo)) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(nodeInfo['table']);
|
||||
return _.isUndefined(nodeInfo['foreign_key']);
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
@ -222,12 +222,14 @@ export default class ForeignKeySchema extends BaseUISchema {
|
||||
id: 'convalidated', label: gettext('Validated?'),
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
readonly: (state)=>{
|
||||
// If we are in table edit mode then
|
||||
if(obj.inTable && obj.top && !obj.top.isNew()) {
|
||||
return !(_.isUndefined(state.oid) || !state.convalidated);
|
||||
}
|
||||
if(!obj.isNew(state) && obj.origData.convalidated) {
|
||||
return true;
|
||||
if(!obj.isNew(state)) {
|
||||
let origData = {};
|
||||
if(obj.inTable && obj.top) {
|
||||
origData = _.find(obj.top.origData['foreign_key'], (r)=>r.cid == state.cid);
|
||||
} else {
|
||||
origData = obj.origData;
|
||||
}
|
||||
return origData.convalidated;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
@ -31,7 +31,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['table']);
|
||||
return _.isUndefined(this.nodeInfo['primary_key']);
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
|
@ -32,7 +32,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
if(_.isUndefined(this.nodeInfo)) {
|
||||
return true;
|
||||
}
|
||||
return _.isUndefined(this.nodeInfo['table']);
|
||||
return _.isUndefined(this.nodeInfo['unique_constraint']);
|
||||
}
|
||||
|
||||
changeColumnOptions(columns) {
|
||||
|
@ -650,7 +650,12 @@ export default class TableSchema extends BaseUISchema {
|
||||
obj.changeColumnOptions(finalCols);
|
||||
return {
|
||||
columns: finalCols,
|
||||
primary_key: []
|
||||
primary_key: [],
|
||||
foreign_key: [],
|
||||
exclude_constraint: [],
|
||||
unique_constraint: [],
|
||||
partition_keys: [],
|
||||
partitions: [],
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -171,7 +171,7 @@ describe('ForeignKeySchema', ()=>{
|
||||
let state = {columns: [{local_column: 'id'}]};
|
||||
let actionObj = {oldState:{name: 'fkname'}};
|
||||
|
||||
schemaObj.nodeInfo = {table: {}};
|
||||
schemaObj.nodeInfo = {foreign_key: {}};
|
||||
state.autoindex = true;
|
||||
state.name = 'fkname';
|
||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
||||
@ -197,7 +197,7 @@ describe('ForeignKeySchema', ()=>{
|
||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({});
|
||||
|
||||
state.oid = null;
|
||||
schemaObj.nodeInfo = {};
|
||||
schemaObj.nodeInfo = {table: {}};
|
||||
schemaObj.top = schemaObj;
|
||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
||||
autoindex: false,
|
||||
|
@ -172,6 +172,11 @@ describe('TableSchema', ()=>{
|
||||
expect(depChange()).toEqual({
|
||||
columns: oftypeColumns,
|
||||
primary_key: [],
|
||||
foreign_key: [],
|
||||
exclude_constraint: [],
|
||||
unique_constraint: [],
|
||||
partition_keys: [],
|
||||
partitions: [],
|
||||
});
|
||||
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
||||
done();
|
||||
@ -208,6 +213,11 @@ describe('TableSchema', ()=>{
|
||||
expect(depChange()).toEqual({
|
||||
columns: oftypeColumns,
|
||||
primary_key: [],
|
||||
foreign_key: [],
|
||||
exclude_constraint: [],
|
||||
unique_constraint: [],
|
||||
partition_keys: [],
|
||||
partitions: [],
|
||||
});
|
||||
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user