mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -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)) {
|
if(_.isUndefined(this.nodeInfo)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.isUndefined(this.nodeInfo['table']);
|
return _.isUndefined(this.nodeInfo['check_constraint']);
|
||||||
}
|
}
|
||||||
|
|
||||||
isReadonly(state) {
|
isReadonly(state) {
|
||||||
|
@ -213,7 +213,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema {
|
|||||||
if(_.isUndefined(this.nodeInfo)) {
|
if(_.isUndefined(this.nodeInfo)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.isUndefined(this.nodeInfo['table']);
|
return _.isUndefined(this.nodeInfo['exclusion_constraint']);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialise(data) {
|
initialise(data) {
|
||||||
|
@ -149,7 +149,7 @@ export default class ForeignKeySchema extends BaseUISchema {
|
|||||||
if(_.isUndefined(nodeInfo)) {
|
if(_.isUndefined(nodeInfo)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.isUndefined(nodeInfo['table']);
|
return _.isUndefined(nodeInfo['foreign_key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeColumnOptions(columns) {
|
changeColumnOptions(columns) {
|
||||||
@ -222,12 +222,14 @@ export default class ForeignKeySchema extends BaseUISchema {
|
|||||||
id: 'convalidated', label: gettext('Validated?'),
|
id: 'convalidated', label: gettext('Validated?'),
|
||||||
type: 'switch', group: gettext('Definition'),
|
type: 'switch', group: gettext('Definition'),
|
||||||
readonly: (state)=>{
|
readonly: (state)=>{
|
||||||
// If we are in table edit mode then
|
if(!obj.isNew(state)) {
|
||||||
if(obj.inTable && obj.top && !obj.top.isNew()) {
|
let origData = {};
|
||||||
return !(_.isUndefined(state.oid) || !state.convalidated);
|
if(obj.inTable && obj.top) {
|
||||||
}
|
origData = _.find(obj.top.origData['foreign_key'], (r)=>r.cid == state.cid);
|
||||||
if(!obj.isNew(state) && obj.origData.convalidated) {
|
} else {
|
||||||
return true;
|
origData = obj.origData;
|
||||||
|
}
|
||||||
|
return origData.convalidated;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
|||||||
if(_.isUndefined(this.nodeInfo)) {
|
if(_.isUndefined(this.nodeInfo)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.isUndefined(this.nodeInfo['table']);
|
return _.isUndefined(this.nodeInfo['primary_key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeColumnOptions(columns) {
|
changeColumnOptions(columns) {
|
||||||
|
@ -32,7 +32,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
|||||||
if(_.isUndefined(this.nodeInfo)) {
|
if(_.isUndefined(this.nodeInfo)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.isUndefined(this.nodeInfo['table']);
|
return _.isUndefined(this.nodeInfo['unique_constraint']);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeColumnOptions(columns) {
|
changeColumnOptions(columns) {
|
||||||
|
@ -650,7 +650,12 @@ export default class TableSchema extends BaseUISchema {
|
|||||||
obj.changeColumnOptions(finalCols);
|
obj.changeColumnOptions(finalCols);
|
||||||
return {
|
return {
|
||||||
columns: finalCols,
|
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 state = {columns: [{local_column: 'id'}]};
|
||||||
let actionObj = {oldState:{name: 'fkname'}};
|
let actionObj = {oldState:{name: 'fkname'}};
|
||||||
|
|
||||||
schemaObj.nodeInfo = {table: {}};
|
schemaObj.nodeInfo = {foreign_key: {}};
|
||||||
state.autoindex = true;
|
state.autoindex = true;
|
||||||
state.name = 'fkname';
|
state.name = 'fkname';
|
||||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
||||||
@ -197,7 +197,7 @@ describe('ForeignKeySchema', ()=>{
|
|||||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({});
|
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({});
|
||||||
|
|
||||||
state.oid = null;
|
state.oid = null;
|
||||||
schemaObj.nodeInfo = {};
|
schemaObj.nodeInfo = {table: {}};
|
||||||
schemaObj.top = schemaObj;
|
schemaObj.top = schemaObj;
|
||||||
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({
|
||||||
autoindex: false,
|
autoindex: false,
|
||||||
|
@ -172,6 +172,11 @@ describe('TableSchema', ()=>{
|
|||||||
expect(depChange()).toEqual({
|
expect(depChange()).toEqual({
|
||||||
columns: oftypeColumns,
|
columns: oftypeColumns,
|
||||||
primary_key: [],
|
primary_key: [],
|
||||||
|
foreign_key: [],
|
||||||
|
exclude_constraint: [],
|
||||||
|
unique_constraint: [],
|
||||||
|
partition_keys: [],
|
||||||
|
partitions: [],
|
||||||
});
|
});
|
||||||
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
||||||
done();
|
done();
|
||||||
@ -208,6 +213,11 @@ describe('TableSchema', ()=>{
|
|||||||
expect(depChange()).toEqual({
|
expect(depChange()).toEqual({
|
||||||
columns: oftypeColumns,
|
columns: oftypeColumns,
|
||||||
primary_key: [],
|
primary_key: [],
|
||||||
|
foreign_key: [],
|
||||||
|
exclude_constraint: [],
|
||||||
|
unique_constraint: [],
|
||||||
|
partition_keys: [],
|
||||||
|
partitions: [],
|
||||||
});
|
});
|
||||||
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns);
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user