diff --git a/frontend/src/pages/raw-execute/raw-execute.tsx b/frontend/src/pages/raw-execute/raw-execute.tsx index cb37ad5..70641e1 100644 --- a/frontend/src/pages/raw-execute/raw-execute.tsx +++ b/frontend/src/pages/raw-execute/raw-execute.tsx @@ -20,9 +20,11 @@ type IRawExecuteCellProps = { const RawExecuteCell: FC = ({ cellId, onAdd, onDelete, showTools }) => { const [code, setCode] = useState(""); + const [submittedCode, setSubmittedCode] = useState(""); const [rawExecute, { data: rows, loading, error }] = useRawExecuteLazyQuery(); const handleRawExecute = useCallback(() => { + setSubmittedCode(code); rawExecute({ variables: { query: code, @@ -40,9 +42,9 @@ const RawExecuteCell: FC = ({ cellId, onAdd, onDelete, sho }, [cellId, onDelete]); - const codeWithoutComments = useMemo(() => { - return code.split("\n").filter(text => !text.startsWith("--")).join("\n"); - }, [code]); + const isCodeAQuery = useMemo(() => { + return submittedCode.split("\n").filter(text => !text.startsWith("--")).join("\n").trim().toLowerCase().startsWith("select"); + }, [submittedCode]); return
@@ -73,8 +75,8 @@ const RawExecuteCell: FC = ({ cellId, onAdd, onDelete, sho
} { - rows != null && - (codeWithoutComments.trim().startsWith("SELECT") + rows != null && submittedCode.length > 0 && + (isCodeAQuery ?
c.Name)} columnTags={rows.RawExecute.Columns.map(c => c.Type)}