diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Common/utils/v1QueryUtils.ts b/frontend/libs/console/legacy-ce/src/lib/components/Common/utils/v1QueryUtils.ts index 44504edd58c..1d5a7fa1df9 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Common/utils/v1QueryUtils.ts +++ b/frontend/libs/console/legacy-ce/src/lib/components/Common/utils/v1QueryUtils.ts @@ -7,10 +7,6 @@ import { ConsoleScope } from '../../Main/ConsoleNotification'; import { BaseTableColumn } from '../../../dataSources/types'; import { sqlEscapeText } from '../../../dataSources/services/postgresql/sqlUtils'; import { FixMe } from '../../../types'; -import { - checkFeatureSupport, - READ_ONLY_RUN_SQL_QUERIES, -} from '../../../helpers/versionUtils'; export type OrderByType = 'asc' | 'desc'; export type OrderByNulls = 'first' | 'last'; @@ -45,7 +41,7 @@ export const getRunSqlQuery = ( source, sql: terminateSql(sql), cascade, - read_only: read_only && !!checkFeatureSupport(READ_ONLY_RUN_SQL_QUERIES), + read_only: read_only, }, }; }; diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/Actions.js b/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/Actions.js index 1c58fb18666..747acb60bfb 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/Actions.js +++ b/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/Actions.js @@ -37,6 +37,7 @@ import { exportMetadata } from '../../../../metadata/actions'; const MAKING_REQUEST = 'RawSQL/MAKING_REQUEST'; const SET_SQL = 'RawSQL/SET_SQL'; const SET_CASCADE_CHECKED = 'RawSQL/SET_CASCADE_CHECKED'; +const SET_READ_ONLY_CHECKED = 'RawSQL/SET_READ_ONLY_CHECKED'; const SET_MIGRATION_CHECKED = 'RawSQL/SET_MIGRATION_CHECKED'; const SET_TRACK_TABLE_CHECKED = 'RawSQL/SET_TRACK_TABLE_CHECKED'; const REQUEST_SUCCESS = 'RawSQL/REQUEST_SUCCESS'; @@ -124,8 +125,8 @@ const executeSQL = (dispatch, getState) => { dispatch({ type: MAKING_REQUEST }); dispatch(showSuccessNotification('Executing the Query...')); - - const { isTableTrackChecked, isCascadeChecked, sql } = getState().rawSQL; + const { isTableTrackChecked, isCascadeChecked, isReadOnlyChecked, sql } = + getState().rawSQL; const { migrationMode, readOnlyMode } = getState().main; const isStatementTimeout = statementTimeout && !isMigration; @@ -139,14 +140,20 @@ const executeSQL = dataSource.getStatementTimeoutSql(statementTimeout), source, false, - readOnlyMode, + isReadOnlyChecked || readOnlyMode, driver ) ); } schemaChangesUp.push( - getRunSqlQuery(sql, source, isCascadeChecked, readOnlyMode, driver) + getRunSqlQuery( + sql, + source, + isCascadeChecked, + isReadOnlyChecked || readOnlyMode, + driver + ) ); const schemaChangesDown = getDownQueryComments(schemaChangesUp, source); @@ -238,6 +245,8 @@ const rawSQLReducer = (state = defaultState, action) => { return { ...state, isMigrationChecked: action.data }; case SET_CASCADE_CHECKED: return { ...state, isCascadeChecked: action.data }; + case SET_READ_ONLY_CHECKED: + return { ...state, isReadOnlyChecked: action.data }; case SET_TRACK_TABLE_CHECKED: return { ...state, @@ -293,6 +302,7 @@ export { executeSQL, SET_SQL, SET_CASCADE_CHECKED, + SET_READ_ONLY_CHECKED, SET_MIGRATION_CHECKED, SET_TRACK_TABLE_CHECKED, modalOpen, diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/RawSQL.js b/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/RawSQL.js index 6829a8652c7..832037a7cc2 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/RawSQL.js +++ b/frontend/libs/console/legacy-ce/src/lib/components/Services/Data/RawSQL/RawSQL.js @@ -18,6 +18,7 @@ import { executeSQL, SET_SQL, SET_CASCADE_CHECKED, + SET_READ_ONLY_CHECKED, SET_MIGRATION_CHECKED, SET_TRACK_TABLE_CHECKED, } from './Actions'; @@ -67,6 +68,7 @@ const checkChangeLang = (sql, selectedDriver) => { * @property {boolean} lastSuccess * @property {boolean} isModalOpen * @property {boolean} isCascadeChecked + * @property {boolean} isReadOnlyChecked * @property {boolean} isMigrationChecked * @property {boolean} isTableTrackChecked * @property {boolean} migrationMode @@ -85,6 +87,7 @@ const RawSQL = ({ lastSuccess, isModalOpen, isCascadeChecked, + isReadOnlyChecked, isMigrationChecked, isTableTrackChecked, migrationMode, @@ -351,6 +354,33 @@ const RawSQL = ({ ); }; + const getReadOnlySection = () => { + return ( +