fix(sqllab): throw errors of commented out query (#23378)

This commit is contained in:
JUST.in DO IT
2023-03-23 16:06:22 -07:00
committed by GitHub
parent 8f846b7ad0
commit d1947f7354
3 changed files with 34 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ import { DropdownButton } from 'src/components/DropdownButton';
import { detectOS } from 'src/utils/common';
import { QueryButtonProps } from 'src/SqlLab/types';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
import { cleanSqlComments } from 'src/SqlLab/actions/sqlLab';
export interface RunQueryActionButtonProps {
queryEditorId: string;
@@ -105,9 +106,7 @@ const RunQueryActionButton = ({
: Button;
const sqlContent = selectedText || sql || '';
const isDisabled =
!sqlContent ||
!sqlContent.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim();
const isDisabled = cleanSqlComments(sqlContent).length === 0;
const stopButtonTooltipText = useMemo(
() =>