Skip to content

Commit

Permalink
feat(frontend): fix up raw execute to not change based on code and ma…
Browse files Browse the repository at this point in the history
…ke the response viewer case in sensitive
  • Loading branch information
hkdeman committed Oct 29, 2024
1 parent 481fd4d commit 033d2fb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frontend/src/pages/raw-execute/raw-execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ type IRawExecuteCellProps = {

const RawExecuteCell: FC<IRawExecuteCellProps> = ({ 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,
Expand All @@ -40,9 +42,9 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ 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 <div className="flex flex-col grow group/cell">
<div className="relative">
Expand Down Expand Up @@ -73,8 +75,8 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
</div>
}
{
rows != null &&
(codeWithoutComments.trim().startsWith("SELECT")
rows != null && submittedCode.length > 0 &&
(isCodeAQuery
?
<div className="flex flex-col w-full h-[250px] mt-4">
<Table columns={rows.RawExecute.Columns.map(c => c.Name)} columnTags={rows.RawExecute.Columns.map(c => c.Type)}
Expand Down

0 comments on commit 033d2fb

Please sign in to comment.