Skip to content

Commit 8857136

Browse files
committed
[fix]: Modify SQL interception and judgment logic
1 parent 5a96d14 commit 8857136

File tree

1 file changed

+10
-1
lines changed
  • packages/shared/lib/components/SQLRenderer/component

1 file changed

+10
-1
lines changed

packages/shared/lib/components/SQLRenderer/component/Snippet.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { SQLRendererStyleWrapper } from '../style';
66
import { Spin, Typography } from 'antd';
77
import { tooltipsCommonProps } from '../../BasicToolTips';
88
import HighlightCode from '../../../utils/HighlightCode';
9+
import { useMemo } from 'react';
10+
import { isNumber } from 'lodash';
911

1012
const Snippet: React.FC<SQLSnippetRendererProps> = ({
1113
rows = 10,
@@ -35,7 +37,14 @@ const Snippet: React.FC<SQLSnippetRendererProps> = ({
3537
onCopyComplete,
3638
copyIconClassName
3739
});
38-
const slicedSql = sql && cuttingLength ? sql.slice(0, cuttingLength) : sql;
40+
41+
const slicedSql = useMemo(() => {
42+
if (isNumber(cuttingLength)) {
43+
return sql?.slice(0, cuttingLength);
44+
}
45+
return sql;
46+
}, [cuttingLength, sql]);
47+
3948
const render = () => {
4049
const content = (
4150
<SQLRendererStyleWrapper

0 commit comments

Comments
 (0)