Skip to content

Commit

Permalink
Merge branch 'dev-4.2.3' of https://code.alipay.com/oceanbase/oceanba…
Browse files Browse the repository at this point in the history
…se-developer-center into dev-4.2.3
  • Loading branch information
HSunboy committed Dec 22, 2023
2 parents ad2bc0a + 4112ad3 commit a3400d6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
51 changes: 42 additions & 9 deletions src/page/Workspace/components/SQLPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
};

public handleExecuteSQL = async () => {
const { params } = this.props;
const { params, sqlStore, pageKey } = this.props;

const selectedSQL = this.editor.getSelectionContent();
const sqlToExecute = selectedSQL || params.scriptText;
Expand All @@ -342,8 +342,21 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
});
}
if (result?.hasLintResults) {
if (
result?.executeResult &&
Array.isArray(result?.executeResult) &&
result?.executeResult?.find((result) => result.status !== ISqlExecuteResultStatus.SUCCESS)
) {
const firstResultKey = sqlStore.getFirstUnlockedResultKey(pageKey);
this.setState({
resultSetTabActiveKey: firstResultKey ? firstResultKey : recordsTabKey,
});
} else if (result?.status !== EStatus.SUBMIT) {
this.setState({
resultSetTabActiveKey: sqlLintTabKey,
});
}
this.setState({
resultSetTabActiveKey: sqlLintTabKey,
lintResultSet: result?.lintResultSet,
executeOrPreCheckSql: sqlToExecute,
sqlChanged: false,
Expand All @@ -359,6 +372,7 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
};
// 执行选中的 SQL
public handleExecuteSelectedSQL = async () => {
const { sqlStore, pageKey } = this.props;
let selectedSQL = this.editor.getModel().getValueInRange(this.editor.getSelection()); // 如果没有选中,尝试获取当前语句
let begin, end;
if (!selectedSQL) {
Expand Down Expand Up @@ -399,8 +413,21 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
});
}
if (results?.hasLintResults) {
if (
results?.executeResult &&
Array.isArray(results?.executeResult) &&
results?.executeResult?.find((result) => result.status !== ISqlExecuteResultStatus.SUCCESS)
) {
const firstResultKey = sqlStore.getFirstUnlockedResultKey(pageKey);
this.setState({
resultSetTabActiveKey: firstResultKey ? firstResultKey : recordsTabKey,
});
} else if (results?.status !== EStatus.SUBMIT) {
this.setState({
resultSetTabActiveKey: sqlLintTabKey,
});
}
this.setState({
resultSetTabActiveKey: sqlLintTabKey,
lintResultSet: results?.lintResultSet,
executeOrPreCheckSql: selectedSQL,
sqlChanged: false,
Expand Down Expand Up @@ -458,8 +485,14 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
}; // 保存 SQL

public handleCreateSQL = async (script: ISQLScript) => {
const { userStore, pageStore, pageKey, onSetUnsavedModalContent, onChangeSaved, params } =
this.props;
const {
userStore,
pageStore,
pageKey,
onSetUnsavedModalContent,
onChangeSaved,
params,
} = this.props;
let existedScriptId;
const newFiles = await newScript(
[new File([params.scriptText], script.objectName)],
Expand Down Expand Up @@ -1192,10 +1225,7 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
this.getSession()?.database?.dbName,
false,
);
if (results?.hasLintResults) {
return results;
}
if (!results || results?.invalid) {
if ((!results || results?.invalid) && !results?.hasLintResults) {
return;
}
this.getSession()?.initSessionStatus();
Expand All @@ -1220,6 +1250,9 @@ export class SQLPage extends Component<IProps, ISQLPageState> {

// await this.refreshResourceTree(results);
this.triggerTableLayout();
if (results?.hasLintResults) {
return results;
}
};

private async showFirrstErrorStmt(
Expand Down
2 changes: 1 addition & 1 deletion src/page/Workspace/components/SQLResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const SQLResultSet: React.FC<IProps> = function (props) {
>
<ExecuteHistory resultHeight={resultHeight} onShowExecuteDetail={onShowExecuteDetail} />
</TabPane>
{lintResultSet ? (
{lintResultSet?.length ? (
<TabPane
tab={
<span className={styles.resultSetTitle}>
Expand Down

0 comments on commit a3400d6

Please sign in to comment.