Fixed an issue where query tool should show results and messages only from the last executed query. #8010

Fixed an issue where query tool should not prompt for unsaved changes when there are no changes. #8127
This commit is contained in:
Rohit Bhati 2024-11-21 10:52:43 +05:30 committed by GitHub
parent 6d5b1673e6
commit 321366489d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import React, {useContext, useCallback, useEffect, useMemo } from 'react';
import { format } from 'sql-formatter'; import { format } from 'sql-formatter';
import { QueryToolContext, QueryToolEventsContext } from '../QueryToolComponent'; import { QueryToolContext, QueryToolEventsContext } from '../QueryToolComponent';
import CodeMirror from '../../../../../../static/js/components/ReactCodeMirror'; import CodeMirror from '../../../../../../static/js/components/ReactCodeMirror';
import {PANELS, QUERY_TOOL_EVENTS} from '../QueryToolConstants'; import {OS_EOL, PANELS, QUERY_TOOL_EVENTS} from '../QueryToolConstants';
import url_for from 'sources/url_for'; import url_for from 'sources/url_for';
import { LayoutDockerContext, LAYOUT_EVENTS } from '../../../../../../static/js/helpers/Layout'; import { LayoutDockerContext, LAYOUT_EVENTS } from '../../../../../../static/js/helpers/Layout';
import ConfirmSaveContent from '../../../../../../static/js/Dialogs/ConfirmSaveContent'; import ConfirmSaveContent from '../../../../../../static/js/Dialogs/ConfirmSaveContent';
@ -190,7 +190,9 @@ export default function Query({onTextSelect, handleEndOfLineChange}) {
editor.current.markClean(); editor.current.markClean();
eventBus.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, fileName, true); eventBus.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, fileName, true);
const lineSep = res.data.includes('\r\n') ? 'crlf' : 'lf'; const lineSep = res.data.includes('\r\n') ? 'crlf' : 'lf';
handleEndOfLineChange(lineSep); if (lineSep !== OS_EOL){
handleEndOfLineChange(lineSep);
}
}).catch((err)=>{ }).catch((err)=>{
eventBus.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, null, false); eventBus.fireEvent(QUERY_TOOL_EVENTS.LOAD_FILE_DONE, null, false);
pgAdmin.Browser.notifier.error(parseApiError(err)); pgAdmin.Browser.notifier.error(parseApiError(err));

View File

@ -753,6 +753,8 @@ export class ResultSetUtils {
} }
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, tabMsg, true); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, tabMsg, true);
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.FOCUS_PANEL, PANELS.MESSAGES); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.FOCUS_PANEL, PANELS.MESSAGES);
/* Clear the query data if the query has no result to display.*/
onResultsAvailable(null, [], []);
} }
return retMsg; return retMsg;
} }

View File

@ -1510,7 +1510,8 @@ Failed to reset the connection to the server due to following error:
for col in self.column_info: for col in self.column_info:
col['pos'] = pos col['pos'] = pos
pos += 1 pos += 1
else:
self.column_info = None
self.row_count = cur.get_rowcount() self.row_count = cur.get_rowcount()
if not no_result and cur.get_rowcount() > 0: if not no_result and cur.get_rowcount() > 0:
result = [] result = []