Skip to content

Commit

Permalink
PullRequest: 594 fixes oceanbase/odc#3420
Browse files Browse the repository at this point in the history
Merge branch 'fix/dev-4.3.3-3420 of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.3

https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/594


Signed-off-by: 晓康 <[email protected]>


* fixes oceanbase/odc#3420
  • Loading branch information
之瑛 committed Dec 12, 2024
1 parent 627929e commit f6a1b31
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/page/Workspace/components/SQLPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getDataSourceModeConfigByConnectionMode } from '@/common/datasource';
import { newScript, updateScript } from '@/common/network';
import { executeSQL, runSQLLint } from '@/common/network/sql';
import { executeTaskManager } from '@/common/network/sql/executeSQL';
import { IExecuteTaskResult } from '@/common/network/sql/preHandle';
import { batchGetDataModifySQL } from '@/common/network/table';
import { ProfileType } from '@/component/ExecuteSqlDetailModal/constant';
import ExecuteSQLModal from '@/component/ExecuteSQLModal';
Expand Down Expand Up @@ -51,10 +52,11 @@ import SessionStore from '@/store/sessionManager/session';
import setting, { SettingStore } from '@/store/setting';
import type { SQLStore } from '@/store/sql';
import { isConnectionModeBeMySQLType } from '@/util/connection';
import { isLogicalDatabase } from '@/util/database';
import utils, { EHighLight } from '@/util/editor';
import { formatMessage } from '@/util/intl';
import notification from '@/util/notification';
import { splitSql } from '@/util/sql';
import { splitSqlForHighlight } from '@/util/sql';
import { generateAndDownloadFile, getCurrentSQL } from '@/util/utils';
import { message, Spin } from 'antd';
import { debounce, isNil } from 'lodash';
Expand All @@ -68,8 +70,6 @@ import Trace from '../Trace';
import ExecDetail from './ExecDetail';
import ExecPlan from './ExecPlan';
import styles from './index.less';
import { isLogicalDatabase } from '@/util/database';
import { IExecuteTaskResult } from '@/common/network/sql/preHandle';

interface ISQLPageState {
resultHeight: number;
Expand Down Expand Up @@ -1344,7 +1344,7 @@ export class SQLPage extends Component<IProps, ISQLPageState> {
for (let i = 0; i < results?.length; i++) {
const result = results[i];
if (result.status !== ISqlExecuteResultStatus.SUCCESS) {
const sqlIndexs = await splitSql(
const sqlIndexs = await splitSqlForHighlight(
this.editor.getValue(),
session.connection?.dialectType === ConnectionMode.MYSQL,
session?.params?.delimiter,
Expand Down
21 changes: 19 additions & 2 deletions src/util/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { getDataSourceModeConfig } from '@/common/datasource';
import { PLType } from '@/constant/plType';
import { ConnectType, ConnectionMode, DbObjectType, IFormatPLSchema, IPLParam } from '@/d.ts';
import { ConnectionMode, ConnectType, DbObjectType, IFormatPLSchema, IPLParam } from '@/d.ts';
import moment from 'moment';
import { Oracle } from './dataType';
import { getQuoteTableName } from './utils';
import { getDataSourceModeConfig } from '@/common/datasource';

/**
* 把一段输入多行注释掉,并且在首行添加comment信息。
Expand Down Expand Up @@ -264,6 +264,23 @@ export async function splitSql(
});
}

export async function splitSqlForHighlight(
sql: string,
isOracle: boolean = false,
delimiter,
): Promise<number[]> {
const { SQLDocument } = await import('@oceanbase-odc/ob-parser-js');
const doc = new SQLDocument({
text: sql,
delimiter: delimiter,
});
return doc?.statements
?.filter((stmt) => !stmt.isDelimiter)
.map((stmt) => {
return stmt.stop + (stmt.delimiter?.length || 0);
});
}

export function getRealTableName(tableName: string, isOracle: boolean = true) {
return getRealNameInDatabase(tableName, isOracle, false);
}
Expand Down

0 comments on commit f6a1b31

Please sign in to comment.