Fix graphical explain now that JSON data is sent as text to stop JS futzing with it. Fixes #4041

This commit is contained in:
Aditya Toshniwal 2019-03-01 12:38:57 +00:00 committed by Dave Page
parent d8f9e3e87b
commit 74cfeabd02

View File

@ -2339,32 +2339,37 @@ define('tools.querytool', [
* In case of Explain draw the graph on explain panel * In case of Explain draw the graph on explain panel
* and add json formatted data to collection and render. * and add json formatted data to collection and render.
*/ */
var explain_data_array = []; var explain_data_array = [],
if ( explain_data_json = null;
data.result && data.result.length >= 1 &&
data.result[0] && data.result[0][0] && data.result[0][0][0] && if(data.types[0].typname === 'json') {
data.result[0][0][0].hasOwnProperty('Plan') && /* json is sent as text, parse it */
_.isObject(data.result[0][0][0]['Plan']) explain_data_json = JSON.parse(data.result[0]);
) {
var explain_data = [JSON.stringify(data.result[0][0], null, 2)]; if (explain_data_json && explain_data_json[0] &&
explain_data_array.push(explain_data); explain_data_json[0].hasOwnProperty('Plan') &&
// Make sure - the 'Data Output' panel is visible, before - we _.isObject(explain_data_json[0]['Plan'])
// start rendering the grid. ) {
self.gridView.data_output_panel.focus(); var explain_data = [JSON.stringify(explain_data_json, null, 2)];
setTimeout( explain_data_array.push(explain_data);
function() { // Make sure - the 'Data Output' panel is visible, before - we
self.gridView.render_grid( // start rendering the grid.
explain_data_array, self.columns, self.can_edit, self.gridView.data_output_panel.focus();
self.client_primary_key setTimeout(
); function() {
// Make sure - the 'Explain' panel is visible, before - we self.gridView.render_grid(
// start rendering the grid. explain_data_array, self.columns, self.can_edit,
self.gridView.explain_panel.focus(); self.client_primary_key
pgExplain.DrawJSONPlan( );
$('.sql-editor-explain'), data.result[0][0] // Make sure - the 'Explain' panel is visible, before - we
); // start rendering the grid.
}, 10 self.gridView.explain_panel.focus();
); pgExplain.DrawJSONPlan(
$('.sql-editor-explain'), explain_data_json
);
}, 10
);
}
} else { } else {
// Make sure - the 'Data Output' panel is visible, before - we // Make sure - the 'Data Output' panel is visible, before - we
// start rendering the grid. // start rendering the grid.