File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ const insertQuery = function (queryType) {
263263 setQuery ( '' ) ;
264264
265265 return ;
266- } else if ( queryType === 'format' ) {
266+ } else if ( queryType === 'format' || queryType === 'formatSingleLine' ) {
267267 if ( window . codeMirrorEditor ) {
268268 $ ( '#querymessage' ) . html ( window . Messages . strFormatting +
269269 ' <img class="ajaxIcon" src="' +
@@ -272,7 +272,8 @@ const insertQuery = function (queryType) {
272272 var params = {
273273 'ajax_request' : true ,
274274 'sql' : window . codeMirrorEditor . getValue ( ) ,
275- 'server' : CommonParams . get ( 'server' )
275+ 'server' : CommonParams . get ( 'server' ) ,
276+ 'formatSingleLine' : queryType === 'formatSingleLine'
276277 } ;
277278 $ . ajax ( {
278279 type : 'POST' ,
Original file line number Diff line number Diff line change 3838 <input type =" button" value =" {{ t(' Clear' ) }}" id =" clear" class =" btn btn-secondary button sqlbutton" >
3939 {% if codemirror_enable %}
4040 <input type =" button" value =" {{ t(' Format' ) }}" id =" format" class =" btn btn-secondary button sqlbutton" >
41+ <input type =" button" value =" {{ t(' Format as a single line' ) }}" id =" formatSingleLine" class =" btn btn-secondary button sqlbutton" >
4142 {% endif %}
4243 </div >
4344
Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ public function __invoke(ServerRequest $request): Response
2323 {
2424 /** @var string $query */
2525 $ query = $ request ->getParsedBodyParam ('sql ' , '' );
26- $ this ->response ->addJSON (['sql ' => Formatter::format ($ query )]);
26+ if ($ request ->getParsedBodyParam ('formatSingleLine ' ) === 'true ' ) {
27+ $ this ->response ->addJSON (['sql ' => Formatter::format ($ query , ['line_ending ' => ' ' , 'indentation ' => '' ])]);
28+ } else {
29+ $ this ->response ->addJSON (['sql ' => Formatter::format ($ query )]);
30+ }
2731
2832 return $ this ->response ->response ();
2933 }
You can’t perform that action at this time.
0 commit comments