File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,7 @@ export function TSQLEditor(opts: TSQLEditorProps) {
178178 if ( ! currentContent . trim ( ) ) return ;
179179
180180 try {
181- const formatted = formatSQL ( currentContent , {
182- language : "sql" ,
183- keywordCase : "upper" ,
184- indentStyle : "standard" ,
185- linesBetweenQueries : 2 ,
186- } ) ;
181+ const formatted = autoFormatSQL ( currentContent ) ;
187182 view . dispatch ( {
188183 changes : { from : 0 , to : view . state . doc . length , insert : formatted } ,
189184 } ) ;
@@ -264,3 +259,12 @@ export function TSQLEditor(opts: TSQLEditorProps) {
264259 </ div >
265260 ) ;
266261}
262+
263+ export function autoFormatSQL ( sql : string ) {
264+ return formatSQL ( sql , {
265+ language : "sql" ,
266+ keywordCase : "upper" ,
267+ indentStyle : "standard" ,
268+ linesBetweenQueries : 2 ,
269+ } ) ;
270+ }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import {
2727} from "~/components/code/ChartConfigPanel" ;
2828import { CodeBlock } from "~/components/code/CodeBlock" ;
2929import { QueryResultsChart } from "~/components/code/QueryResultsChart" ;
30- import { TSQLEditor } from "~/components/code/TSQLEditor" ;
30+ import { autoFormatSQL , TSQLEditor } from "~/components/code/TSQLEditor" ;
3131import { TSQLResultsTable } from "~/components/code/TSQLResultsTable" ;
3232import {
3333 ClientTabs ,
@@ -487,7 +487,10 @@ export default function Page() {
487487 editorRef . current ?. setQuery ( exampleQuery ) ;
488488 editorRef . current ?. setScope ( exampleScope ) ;
489489 } }
490- onQueryGenerated = { ( query ) => editorRef . current ?. setQuery ( query ) }
490+ onQueryGenerated = { ( query ) => {
491+ const formatted = autoFormatSQL ( query ) ;
492+ editorRef . current ?. setQuery ( formatted ) ;
493+ } }
491494 getCurrentQuery = { ( ) => editorRef . current ?. getQuery ( ) ?? "" }
492495 />
493496 </ ResizablePanel >
You can’t perform that action at this time.
0 commit comments