Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en_US/release_notes_9_16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Housekeeping

Bug fixes
*********

| `Issue #9060 <https://github.com/pgadmin-org/pgadmin4/issues/9060>`_ - Fixed an issue in the Create/Edit Table dialog where renaming a column did not update the column references in foreign key and unique constraint definitions for the new table.
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,25 @@ export class ConstraintsSchema extends BaseUISchema {
disabled: this.inCatalog,
canAddRow: obj.anyColumnAdded,
expandEditOnAdd: true,
depChange: (state)=>{
depChange: (state, source, topState, actionObj)=>{
if (state.is_partitioned && obj.top.getServerVersion() < 110000 || state.columns?.length <= 0) {
return {foreign_key: []};
}
/* If a column is renamed, sync the foreign key local column references. #9060 */
if(actionObj.type == SCHEMA_STATE_ACTIONS.SET_VALUE && actionObj.path[0] == 'columns' &&
actionObj.path[actionObj.path.length-1] == 'name' && state.oid === undefined &&
state.foreign_key?.length) {
let oldName = actionObj.oldState.columns[actionObj.path[1]]?.name,
newName = _.get(state, _.slice(actionObj.path, 0, -1))?.name;
if(oldName && newName && oldName !== newName) {
return {foreign_key: state.foreign_key.map((fk)=>({
...fk,
columns: fk.columns?.map((c)=>(
c.local_column === oldName ? {...c, local_column: newName} : c
)),
}))};
}
Comment on lines +207 to +220
}
}
},{
id: 'check_group', type: 'group', label: gettext('Check'), visible: !this.inErd,
Expand All @@ -223,18 +238,33 @@ export class ConstraintsSchema extends BaseUISchema {
schema: this.uniqueConsObj,
editable: false, type: 'collection',
group: 'unique_group', mode: ['edit', 'create'],
canEdit: true, canDelete: true, deps:['is_partitioned', 'typname'],
canEdit: true, canDelete: true, deps:['is_partitioned', 'typname', 'columns'],
columns : ['name', 'columns'],
disabled: this.inCatalog,
canAdd: function(state) {
return obj.canAdd(state);
},
canAddRow: obj.anyColumnAdded,
expandEditOnAdd: true,
depChange: (state)=>{
depChange: (state, source, topState, actionObj)=>{
if (state.is_partitioned && obj.top.getServerVersion() < 110000 || state.columns?.length <= 0) {
return {unique_constraint: []};
}
/* If a column is renamed, sync the unique constraint column references. #9060 */
if(actionObj.type == SCHEMA_STATE_ACTIONS.SET_VALUE && actionObj.path[0] == 'columns' &&
actionObj.path[actionObj.path.length-1] == 'name' && state.oid === undefined &&
state.unique_constraint?.length) {
let oldName = actionObj.oldState.columns[actionObj.path[1]]?.name,
newName = _.get(state, _.slice(actionObj.path, 0, -1))?.name;
if(oldName && newName && oldName !== newName) {
return {unique_constraint: state.unique_constraint.map((uc)=>({
...uc,
columns: uc.columns?.map((c)=>(
c.column === oldName ? {...c, column: newName} : c
)),
}))};
Comment on lines +260 to +265
}
}
}
},{
id: 'exclude_group', type: 'group', label: gettext('Exclude'), visible: !this.inErd,
Expand Down
Loading