Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(sql-editor): commit changed data instead of fetching (#464)
STEVEN3ac3a3ef3393
diff --git a/frontend/src/store/modules/sqlEditor.ts b/frontend/src/store/modules/sqlEditor.tsindex 0d3f469e27..b8392b2f64 100644--- a/frontend/src/store/modules/sqlEditor.ts+++ b/frontend/src/store/modules/sqlEditor.ts@@ -31,13 +31,14 @@ const state: () => SqlEditorState = () => ({selectedDatabaseId: 0,selectedTableName: "",},+ isExecuting: false,+ isShowExecutingHint: false,shouldSetContent: false,+ // Related data and statusqueryHistoryList: [],isFetchingQueryHistory: false,savedQueryList: [],isFetchingSavedQueries: false,- isExecuting: false,- isShowExecutingHint: false,});const getters = {@@ -136,6 +137,9 @@ const mutations = {[types.SET_SHOULD_SET_CONTENT](state: SqlEditorState, payload: boolean) {state.shouldSetContent = payload;},+ [types.SET_IS_EXECUTING](state: SqlEditorState, payload: boolean) {+ state.isExecuting = payload;+ },[types.SET_QUERY_HISTORY_LIST](state: SqlEditorState,payload: QueryHistory[]@@ -157,10 +161,6 @@ const mutations = {) {state.isFetchingSavedQueries = payload;},-- [types.SET_IS_EXECUTING](state: SqlEditorState, payload: boolean) {- state.isExecuting = payload;- },};type SqlEditorActionsMap = {@@ -168,11 +168,11 @@ type SqlEditorActionsMap = {setConnectionTree: typeof mutations.SET_CONNECTION_TREE;setConnectionContext: typeof mutations.SET_CONNECTION_CONTEXT;setShouldSetContent: typeof mutations.SET_SHOULD_SET_CONTENT;+ setIsExecuting: typeof mutations.SET_IS_EXECUTING;setQueryHistoryList: typeof mutations.SET_QUERY_HISTORY_LIST;setIsFetchingQueryHistory: typeof mutations.SET_IS_FETCHING_QUERY_HISTORY;setSavedQueryList: typeof mutations.SET_SAVED_QUERY_LIST;setIsFetchingSavedQueries: typeof mutations.SET_IS_FETCHING_SAVED_QUERIES;- setIsExecuting: typeof mutations.SET_IS_EXECUTING;};const actions = {@@ -181,11 +181,11 @@ const actions = {setConnectionTree: types.SET_CONNECTION_TREE,setConnectionContext: types.SET_CONNECTION_CONTEXT,setShouldSetContent: types.SET_SHOULD_SET_CONTENT,+ setIsExecuting: types.SET_IS_EXECUTING,setQueryHistoryList: types.SET_QUERY_HISTORY_LIST,setIsFetchingQueryHistory: types.SET_IS_FETCHING_QUERY_HISTORY,setSavedQueryList: types.SET_SAVED_QUERY_LIST,setIsFetchingSavedQueries: types.SET_IS_FETCHING_SAVED_QUERIES,- setIsExecuting: types.SET_IS_EXECUTING,}),async executeQuery({ dispatch, state, rootGetters }: any,@@ -271,14 +271,18 @@ const actions = {);commit(types.SET_IS_FETCHING_QUERY_HISTORY, false);},- async deleteQueryHistory({ dispatch }: any, id: number) {+ async deleteQueryHistory({ commit, dispatch, state }: any, id: number) {await dispatch("activity/deleteActivityById", id, {root: true,});- dispatch("fetchQueryHistoryList");++ commit(+ types.SET_QUERY_HISTORY_LIST,+ state.queryHistoryList.filter((t: QueryHistory) => t.id !== id)+ );},async createSavedQuery(- { dispatch }: any,+ { commit, state }: any,{ name, statement }: { name: string; statement: string }): Promise<SavedQuery> {const resData = (@@ -292,14 +296,22 @@ const actions = {},})).data.data;- dispatch("fetchSavedQueryList");- return {+ const newSavedQuery = {...(resData.attributes as Omit<SavedQuery, "id">),id: parseInt(resData.id),- };+ } as SavedQuery;++ commit(+ types.SET_SAVED_QUERY_LIST,+ (state.savedQueryList as SavedQuery[])+ .concat(newSavedQuery)+ .sort((a, b) => b.createdTs - a.createdTs)+ );++ return newSavedQuery;},- async fetchSavedQueryList({ commit, dispatch }: any) {+ async fetchSavedQueryList({ commit }: any) {commit(types.SET_IS_FETCHING_SAVED_QUERIES, true);const data = (await axios.get(`/api/savedquery`)).data;const savedQueryList: SavedQuery[] = data.data.map(@@ -345,9 +357,12 @@ const actions = {});dispatch("fetchSavedQueryList");},- async deleteSavedQuery({ dispatch }: any, id: number) {+ async deleteSavedQuery({ commit, state }: any, id: number) {await axios.delete(`/api/savedquery/${id}`);- dispatch("fetchSavedQueryList");+ commit(+ types.SET_SAVED_QUERY_LIST,+ state.savedQueryList.filter((t: SavedQuery) => t.id !== id)+ );},async checkSavedQueryExistById({ state }: any, id: number) {for (const savedQuery of state.savedQueryList) {