Fixed an error while saving changes to the ERD table. Fixes #5342

This commit is contained in:
Aditya Toshniwal 2022-09-19 16:20:07 +05:30 committed by Akshay Joshi
parent e2b00dda1b
commit a2a18d4b4a
4 changed files with 32 additions and 13 deletions

View File

@ -44,4 +44,5 @@ Bug fixes
| `Issue #5323 <https://github.com/postgres/pgadmin4/issues/5323>`_ - Replace the language selection 'Brazilian' with 'Portuguese (Brazilian). (RM #7693)
| `Issue #5325 <https://github.com/postgres/pgadmin4/issues/5325>`_ - Fixed an issue where server names with special characters are not displayed correctly in the process tab. (RM #7695)
| `Issue #5333 <https://github.com/postgres/pgadmin4/issues/5333>`_ - Fixed an issue where ERD throws an error if variable is added to the column. (RM #7709)
| `Issue #5342 <https://github.com/postgres/pgadmin4/issues/5342>`_ - Fixed an error while saving changes to the ERD table.
| `Issue #5343 <https://github.com/postgres/pgadmin4/issues/5343>`_ - Fixes a redirect vulnerability when the user opens the pgAdmin URL.

View File

@ -92,6 +92,15 @@ const useStyles = makeStyles((theme)=>({
'&.Mui-disabled': {
border: 0,
},
},
noBorderPrimary: {
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.primary.main,
'&:hover': {
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.primary.hoverMain,
borderColor: theme.palette.primary.hoverBorderColor,
},
}
}));
@ -104,7 +113,7 @@ export const PrimaryButton = forwardRef((props, ref)=>{
size = undefined;
allClassName.push(classes.xsButton);
}
noBorder && allClassName.push(classes.noBorder);
noBorder && allClassName.push(...[classes.noBorder, classes.noBorderPrimary]);
const dataLabel = typeof(children) == 'string' ? children : undefined;
return (
<Button ref={ref} size={size} className={clsx(allClassName)} data-label={dataLabel} {...otherProps} variant="contained" color="primary">{children}</Button>

View File

@ -71,17 +71,21 @@ function parseString(string) {
}
function parseQuery(query, useRegex=false, matchCase=false) {
if (useRegex) {
query = new RegExp(query, matchCase ? 'g': 'gi');
} else {
query = parseString(query);
if(!matchCase) {
query = query.toLowerCase();
try {
if (useRegex) {
query = new RegExp(query, matchCase ? 'g': 'gi');
} else {
query = parseString(query);
if(!matchCase) {
query = query.toLowerCase();
}
}
if (typeof query == 'string' ? query == '' : query.test(''))
query = /x^/;
return query;
} catch (error) {
return null;
}
if (typeof query == 'string' ? query == '' : query.test(''))
query = /x^/;
return query;
}
function getRegexFinder(query) {
@ -143,6 +147,8 @@ export function FindDialog({editor, show, replace, onClose}) {
const search = ()=>{
if(editor) {
let query = parseQuery(findVal, useRegex, matchCase);
if(!query) return;
searchCursor.current = editor.getSearchCursor(query, 0, !matchCase);
if(findVal != '') {
editor.removeOverlay(highlightsearch.current);

View File

@ -305,11 +305,14 @@ export default class ERDCore {
let fkTableNode = this.getModel().getNodesDict()[linkData.local_table_uid];
let newForeingKeys = [];
/* Update the FK table with new references */
fkTableNode.getData().foreign_key?.forEach((theFkRow)=>{
for(let fkColumn of theFkRow.columns) {
let attnum = _.find(oldTableData.columns, (c)=>c.name==fkColumn.referenced).attnum;
fkColumn.referenced = _.find(tableData.columns, (colm)=>colm.attnum==attnum).name;
fkColumn.references_table_name = tableData.name;
if(fkColumn.references == tableNode.getID()) {
let attnum = _.find(oldTableData.columns, (c)=>c.name==fkColumn.referenced).attnum;
fkColumn.referenced = _.find(tableData.columns, (colm)=>colm.attnum==attnum).name;
fkColumn.references_table_name = tableData.name;
}
}
newForeingKeys.push(theFkRow);
});