mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where Debugger is not getting started if arguments loaded from SQLite database. Fixes #6132
This commit is contained in:
parent
e8f0454b39
commit
41ceda01d0
@ -1836,6 +1836,9 @@ def set_arguments_sqlite(sid, did, scid, func_id):
|
|||||||
|
|
||||||
# handle the Array list sent from the client
|
# handle the Array list sent from the client
|
||||||
array_string = ''
|
array_string = ''
|
||||||
|
if 'value' in data[i]:
|
||||||
|
array_string = data[i]['value']
|
||||||
|
|
||||||
if 'is_array_value' in data[i] and 'value' in data[i] and data[i][
|
if 'is_array_value' in data[i] and 'value' in data[i] and data[i][
|
||||||
'is_array_value']:
|
'is_array_value']:
|
||||||
array_string = get_array_string(data, i)
|
array_string = get_array_string(data, i)
|
||||||
|
@ -143,7 +143,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
let funcArgsData = [];
|
let funcArgsData = [];
|
||||||
if (res.data.data.args_count != 0) {
|
if (res.data.data.args_count != 0) {
|
||||||
setIsDisableDebug(false);
|
setIsDisableDebug(false);
|
||||||
for(const i of res.data.data.result) {
|
for (const i of res.data.data.result) {
|
||||||
// Below will format the data to be stored in sqlite database
|
// Below will format the data to be stored in sqlite database
|
||||||
funcArgsData.push({
|
funcArgsData.push({
|
||||||
'arg_id': i['arg_id'],
|
'arg_id': i['arg_id'],
|
||||||
@ -246,9 +246,9 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
return myObj;
|
return myObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFuncObj(funcArgsData, argMode, argType, argName, defValList, isUnnamedParam=false) {
|
function setFuncObj(funcArgsData, argMode, argType, argName, defValList, isUnnamedParam = false) {
|
||||||
let index, values, funcObj=[];
|
let index, values, funcObj = [];
|
||||||
for(const argData of funcArgsData) {
|
for (const argData of funcArgsData) {
|
||||||
index = argData['arg_id'];
|
index = argData['arg_id'];
|
||||||
if (debuggerInfo['proargmodes'] != null &&
|
if (debuggerInfo['proargmodes'] != null &&
|
||||||
(argMode && argMode[index] == 'o' && !isEdbProc) && !isUnnamedParam) {
|
(argMode && argMode[index] == 'o' && !isEdbProc) && !isUnnamedParam) {
|
||||||
@ -278,7 +278,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setUnnamedParamNonDefVal(argType, defValList, myargname) {
|
function setUnnamedParamNonDefVal(argType, defValList, myargname) {
|
||||||
let myObj= [];
|
let myObj = [];
|
||||||
for (let i = 0; i < argType.length; i++) {
|
for (let i = 0; i < argType.length; i++) {
|
||||||
myObj.push({
|
myObj.push({
|
||||||
'name': myargname[i],
|
'name': myargname[i],
|
||||||
@ -508,13 +508,15 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update values if any change in the args.
|
// Update values if any change in the args.
|
||||||
debuggerFinalArgs.current.changed.forEach(changedArg => {
|
if (debuggerFinalArgs.current) {
|
||||||
argsList.forEach((el, _index) => {
|
debuggerFinalArgs.current.changed.forEach(changedArg => {
|
||||||
if(changedArg.name == el.name) {
|
argsList.forEach((el, _index) => {
|
||||||
argsList[_index] = changedArg;
|
if (changedArg.name == el.name) {
|
||||||
}
|
argsList[_index] = changedArg;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,173 +694,180 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
function startDebugging() {
|
function startDebugging() {
|
||||||
var self = this;
|
var self = this;
|
||||||
setLoaderText('Starting debugger.');
|
setLoaderText('Starting debugger.');
|
||||||
/* Initialize the target once the debug button is clicked and create asynchronous connection
|
try {
|
||||||
and unique transaction ID If the debugging is started again then treeInfo is already stored. */
|
/* Initialize the target once the debug button is clicked and create asynchronous connection
|
||||||
var [treeInfo, d] = getSelectedNodeData();
|
and unique transaction ID If the debugging is started again then treeInfo is already stored. */
|
||||||
if(!d) return;
|
var [treeInfo, d] = getSelectedNodeData();
|
||||||
|
if (!d) return;
|
||||||
|
|
||||||
var argsValueList = [];
|
var argsValueList = [];
|
||||||
var sqliteFuncArgsList = [];
|
var sqliteFuncArgsList = [];
|
||||||
var intCount = 0;
|
var intCount = 0;
|
||||||
|
|
||||||
let argsList = []; //debuggerFinalArgs.current?.changed ? [] : debuggerArgsData.current.aregsCollection;
|
let argsList = []; //debuggerFinalArgs.current?.changed ? [] : debuggerArgsData.current.aregsCollection;
|
||||||
let argSet = [];
|
let argSet = [];
|
||||||
|
|
||||||
setDebuggingArgs(argsList, argSet);
|
setDebuggingArgs(argsList, argSet);
|
||||||
|
|
||||||
argsList.forEach(arg => {
|
argsList.forEach(arg => {
|
||||||
checkArgsVal(arg, argsValueList);
|
checkArgsVal(arg, argsValueList);
|
||||||
setSqliteFuncArgs(d, treeInfo, arg, intCount, sqliteFuncArgsList);
|
setSqliteFuncArgs(d, treeInfo, arg, intCount, sqliteFuncArgsList);
|
||||||
intCount = intCount + 1;
|
intCount = intCount + 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
var baseUrl;
|
var baseUrl;
|
||||||
|
|
||||||
/* If debugging is not started again then we should initialize the target otherwise not */
|
/* If debugging is not started again then we should initialize the target otherwise not */
|
||||||
if (restartDebug == 0) {
|
if (restartDebug == 0) {
|
||||||
baseUrl = checkTypeAndGetUrl(d, treeInfo);
|
baseUrl = checkTypeAndGetUrl(d, treeInfo);
|
||||||
|
|
||||||
api({
|
api({
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: JSON.stringify(argsValueList),
|
data: JSON.stringify(argsValueList),
|
||||||
})
|
|
||||||
.then(function (res_post) {
|
|
||||||
|
|
||||||
var url = url_for(
|
|
||||||
'debugger.direct', {
|
|
||||||
'trans_id': res_post.data.data.debuggerTransId,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var browserPreferences = pgAdmin.Browser.get_preferences_for_module('browser');
|
|
||||||
var open_new_tab = browserPreferences.new_browser_tab_open;
|
|
||||||
if (open_new_tab && open_new_tab.includes('debugger')) {
|
|
||||||
window.open(url, '_blank');
|
|
||||||
// Send the signal to runtime, so that proper zoom level will be set.
|
|
||||||
setTimeout(function () {
|
|
||||||
pgAdmin.Browser.send_signal_to_runtime('Runtime new window opened');
|
|
||||||
}, 500);
|
|
||||||
} else {
|
|
||||||
pgAdmin.Browser.Events.once(
|
|
||||||
'pgadmin-browser:frame:urlloaded:frm_debugger',
|
|
||||||
function (frame) {
|
|
||||||
frame.openURL(url);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the debugger panel as per the data received from user input dialog.
|
|
||||||
var propertiesPanel = pgAdmin.Browser.docker.findPanels('properties');
|
|
||||||
var panel = pgAdmin.Browser.docker.addPanel(
|
|
||||||
'frm_debugger', wcDocker.DOCK.STACKED, propertiesPanel[0]
|
|
||||||
);
|
|
||||||
var browser_pref = pgAdmin.Browser.get_preferences_for_module('browser');
|
|
||||||
var label = getAppropriateLabel(treeInfo);
|
|
||||||
setDebuggerTitle(panel, browser_pref, label, treeInfo.schema.label, treeInfo.database.label, null, pgAdmin.Browser);
|
|
||||||
panel.focus();
|
|
||||||
|
|
||||||
// Panel Closed event
|
|
||||||
panel.on(wcDocker.EVENT.CLOSED, function () {
|
|
||||||
var closeUrl = url_for('debugger.close', {
|
|
||||||
'trans_id': res_post.data.data.debuggerTransId,
|
|
||||||
});
|
|
||||||
api({
|
|
||||||
url: closeUrl,
|
|
||||||
method: 'DELETE',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
/* TO-DO check how to add this is new lib for wc-docker */
|
|
||||||
commonUtils.registerDetachEvent(panel);
|
|
||||||
|
|
||||||
// Panel Rename event
|
|
||||||
panel.on(wcDocker.EVENT.RENAME, function (panel_data) {
|
|
||||||
Alertify.prompt('', panel_data.$titleText[0].textContent,
|
|
||||||
// We will execute this function when user clicks on the OK button
|
|
||||||
function (evt, value) {
|
|
||||||
if (value) {
|
|
||||||
// Remove the leading and trailing white spaces.
|
|
||||||
value = value.trim();
|
|
||||||
var name = getAppropriateLabel(treeInfo);
|
|
||||||
setDebuggerTitle(panel, self.preferences, name, treeInfo.schema.label, treeInfo.database.label, value, pgAdmin.Browser);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// We will execute this function when user clicks on the Cancel
|
|
||||||
// button. Do nothing just close it.
|
|
||||||
function (evt) { evt.cancel = false; }
|
|
||||||
).set({ 'title': gettext('Rename Panel') });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var _url = getSetArgsUrl(d, treeInfo);
|
|
||||||
|
|
||||||
api({
|
|
||||||
url: _url,
|
|
||||||
method: 'POST',
|
|
||||||
data: JSON.stringify(sqliteFuncArgsList),
|
|
||||||
})
|
|
||||||
.then(function () {/*This is intentional (SonarQube)*/ })
|
|
||||||
.catch((error) => {
|
|
||||||
setLoaderText('');
|
|
||||||
Notify.alert(
|
|
||||||
gettext('Error occured: '),
|
|
||||||
gettext(error.response.data)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
/* Close the debugger modal dialog */
|
|
||||||
props.closeModal();
|
|
||||||
setLoaderText('');
|
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.then(function (res_post) {
|
||||||
setLoaderText('');
|
|
||||||
Notify.alert(
|
var url = url_for(
|
||||||
gettext('Debugger Target Initialization Error'),
|
'debugger.direct', {
|
||||||
gettext(error.response.data)
|
'trans_id': res_post.data.data.debuggerTransId,
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var browserPreferences = pgAdmin.Browser.get_preferences_for_module('browser');
|
||||||
|
var open_new_tab = browserPreferences.new_browser_tab_open;
|
||||||
|
if (open_new_tab && open_new_tab.includes('debugger')) {
|
||||||
|
window.open(url, '_blank');
|
||||||
|
// Send the signal to runtime, so that proper zoom level will be set.
|
||||||
|
setTimeout(function () {
|
||||||
|
pgAdmin.Browser.send_signal_to_runtime('Runtime new window opened');
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
pgAdmin.Browser.Events.once(
|
||||||
|
'pgadmin-browser:frame:urlloaded:frm_debugger',
|
||||||
|
function (frame) {
|
||||||
|
frame.openURL(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the debugger panel as per the data received from user input dialog.
|
||||||
|
var propertiesPanel = pgAdmin.Browser.docker.findPanels('properties');
|
||||||
|
var panel = pgAdmin.Browser.docker.addPanel(
|
||||||
|
'frm_debugger', wcDocker.DOCK.STACKED, propertiesPanel[0]
|
||||||
|
);
|
||||||
|
var browser_pref = pgAdmin.Browser.get_preferences_for_module('browser');
|
||||||
|
var label = getAppropriateLabel(treeInfo);
|
||||||
|
setDebuggerTitle(panel, browser_pref, label, treeInfo.schema.label, treeInfo.database.label, null, pgAdmin.Browser);
|
||||||
|
panel.focus();
|
||||||
|
|
||||||
|
// Panel Closed event
|
||||||
|
panel.on(wcDocker.EVENT.CLOSED, function () {
|
||||||
|
var closeUrl = url_for('debugger.close', {
|
||||||
|
'trans_id': res_post.data.data.debuggerTransId,
|
||||||
|
});
|
||||||
|
api({
|
||||||
|
url: closeUrl,
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/* TO-DO check how to add this is new lib for wc-docker */
|
||||||
|
commonUtils.registerDetachEvent(panel);
|
||||||
|
|
||||||
|
// Panel Rename event
|
||||||
|
panel.on(wcDocker.EVENT.RENAME, function (panel_data) {
|
||||||
|
Alertify.prompt('', panel_data.$titleText[0].textContent,
|
||||||
|
// We will execute this function when user clicks on the OK button
|
||||||
|
function (evt, value) {
|
||||||
|
if (value) {
|
||||||
|
// Remove the leading and trailing white spaces.
|
||||||
|
value = value.trim();
|
||||||
|
var name = getAppropriateLabel(treeInfo);
|
||||||
|
setDebuggerTitle(panel, self.preferences, name, treeInfo.schema.label, treeInfo.database.label, value, pgAdmin.Browser);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// We will execute this function when user clicks on the Cancel
|
||||||
|
// button. Do nothing just close it.
|
||||||
|
function (evt) { evt.cancel = false; }
|
||||||
|
).set({ 'title': gettext('Rename Panel') });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var _url = getSetArgsUrl(d, treeInfo);
|
||||||
|
|
||||||
|
api({
|
||||||
|
url: _url,
|
||||||
|
method: 'POST',
|
||||||
|
data: JSON.stringify(sqliteFuncArgsList),
|
||||||
|
})
|
||||||
|
.then(function () {/*This is intentional (SonarQube)*/ })
|
||||||
|
.catch((error) => {
|
||||||
|
setLoaderText('');
|
||||||
|
Notify.alert(
|
||||||
|
gettext('Error occured: '),
|
||||||
|
gettext(error.response.data)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
/* Close the debugger modal dialog */
|
||||||
|
props.closeModal();
|
||||||
|
setLoaderText('');
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
setLoaderText('');
|
||||||
|
Notify.alert(
|
||||||
|
gettext('Debugger Target Initialization Error'),
|
||||||
|
gettext(error.response.data)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If the debugging is started again then we should only set the
|
||||||
|
// arguments and start the listener again
|
||||||
|
baseUrl = url_for('debugger.start_listener', {
|
||||||
|
'trans_id': transId,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
api({
|
||||||
else {
|
url: baseUrl,
|
||||||
// If the debugging is started again then we should only set the
|
method: 'POST',
|
||||||
// arguments and start the listener again
|
data: JSON.stringify(argsValueList),
|
||||||
baseUrl = url_for('debugger.start_listener', {
|
})
|
||||||
'trans_id': transId,
|
.then(function () {/*This is intentional (SonarQube)*/ })
|
||||||
});
|
.catch(function (error) {
|
||||||
|
Notify.alert(
|
||||||
api({
|
gettext('Debugger Listener Startup Error'),
|
||||||
url: baseUrl,
|
gettext(error.response.data)
|
||||||
method: 'POST',
|
);
|
||||||
data: JSON.stringify(argsValueList),
|
});
|
||||||
})
|
setLoaderText('');
|
||||||
.then(function () {/*This is intentional (SonarQube)*/ })
|
// Set the new input arguments given by the user during debugging
|
||||||
.catch(function (error) {
|
var _Url = url_for('debugger.set_arguments', {
|
||||||
Notify.alert(
|
'sid': debuggerInfo.server_id,
|
||||||
gettext('Debugger Listener Startup Error'),
|
'did': debuggerInfo.database_id,
|
||||||
gettext(error.response.data)
|
'scid': debuggerInfo.schema_id,
|
||||||
);
|
'func_id': debuggerInfo.function_id,
|
||||||
});
|
});
|
||||||
|
api({
|
||||||
|
url: _Url,
|
||||||
|
method: 'POST',
|
||||||
|
data: JSON.stringify(sqliteFuncArgsList),
|
||||||
|
})
|
||||||
|
.then(function () {/*This is intentional (SonarQube)*/ })
|
||||||
|
.catch(function (error) {
|
||||||
|
setLoaderText('');
|
||||||
|
Notify.alert(
|
||||||
|
gettext('Debugger Listener Startup Set Arguments Error'),
|
||||||
|
gettext(error.response.data)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
setLoaderText('');
|
setLoaderText('');
|
||||||
// Set the new input arguments given by the user during debugging
|
Notify.alert(
|
||||||
var _Url = url_for('debugger.set_arguments', {
|
gettext('Debugger Error'),
|
||||||
'sid': debuggerInfo.server_id,
|
gettext(err.message)
|
||||||
'did': debuggerInfo.database_id,
|
);
|
||||||
'scid': debuggerInfo.schema_id,
|
|
||||||
'func_id': debuggerInfo.function_id,
|
|
||||||
});
|
|
||||||
api({
|
|
||||||
url: _Url,
|
|
||||||
method: 'POST',
|
|
||||||
data: JSON.stringify(sqliteFuncArgsList),
|
|
||||||
})
|
|
||||||
.then(function () {/*This is intentional (SonarQube)*/ })
|
|
||||||
.catch(function (error) {
|
|
||||||
setLoaderText('');
|
|
||||||
Notify.alert(
|
|
||||||
gettext('Debugger Listener Startup Set Arguments Error'),
|
|
||||||
gettext(error.response.data)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -878,20 +887,20 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
|||||||
onDataChange={(isChanged, changedData) => {
|
onDataChange={(isChanged, changedData) => {
|
||||||
let isValid = false;
|
let isValid = false;
|
||||||
let skipStep = false;
|
let skipStep = false;
|
||||||
if('_sessData' in debuggerArgsSchema.current) {
|
if ('_sessData' in debuggerArgsSchema.current) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
debuggerArgsSchema.current._sessData.aregsCollection.forEach((data)=> {
|
debuggerArgsSchema.current._sessData.aregsCollection.forEach((data) => {
|
||||||
|
|
||||||
if(skipStep) {return;}
|
if (skipStep) { return; }
|
||||||
|
|
||||||
if((data.is_null || data.use_default || data?.value?.toString()?.length > 0) && isValid) {
|
if ((data.is_null || data.use_default || data?.value?.toString()?.length > 0) && isValid) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
} else {
|
} else {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
skipStep = true;
|
skipStep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!data.isValid) {
|
if (!data.isValid) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
skipStep = true;
|
skipStep = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user