这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions console/src/components/Services/Data/RawSQL/RawSQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,36 @@ const RawSQL = ({
);
}

const submitSQL = () => {
// check migration mode global
if (migrationMode) {
const checkboxElem = document.getElementById('migration-checkbox');
const isMigration = checkboxElem ? checkboxElem.checked : false;
if (!isMigration && globals.consoleMode === 'cli') {
// if migration is not checked, check if the sql text has any of 'create', 'alter', 'drop'
const formattedSql = sql.toLowerCase();
if (
formattedSql.indexOf('create') !== -1 ||
formattedSql.indexOf('alter') !== -1 ||
formattedSql.indexOf('drop') !== -1
) {
// const confirmation = window.confirm('Your SQL Statement has a schema modifying command. Are you sure its not a migration?');
dispatch(modalOpen());
const confirmation = false;
if (confirmation) {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(false));
}
};

const onModalClose = () => {
dispatch(modalClose());
};
Expand Down Expand Up @@ -184,6 +214,15 @@ const RawSQL = ({
maxLines={100}
width="100%"
showPrintMargin={false}
commands={[
{
name: 'submit',
bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' },
exec: () => {
submitSQL();
},
},
]}
onChange={val => {
dispatch({ type: SET_SQL, data: val });
const formattedSql = val.toLowerCase();
Expand Down Expand Up @@ -282,37 +321,7 @@ const RawSQL = ({
<button
type="submit"
className={styles.yellow_button}
onClick={() => {
// check migration mode global
if (migrationMode) {
const checkboxElem = document.getElementById(
'migration-checkbox'
);
const isMigration = checkboxElem ? checkboxElem.checked : false;
if (!isMigration && globals.consoleMode === 'cli') {
// if migration is not checked, check if the sql text has any of 'create', 'alter', 'drop'
const formattedSql = sql.toLowerCase();
if (
formattedSql.indexOf('create') !== -1 ||
formattedSql.indexOf('alter') !== -1 ||
formattedSql.indexOf('drop') !== -1
) {
// const confirmation = window.confirm('Your SQL Statement has a schema modifying command. Are you sure its not a migration?');
dispatch(modalOpen());
const confirmation = false;
if (confirmation) {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(isMigration));
}
} else {
dispatch(executeSQL(false));
}
}}
onClick={submitSQL}
data-test="run-sql"
>
Run!
Expand Down