diff --git a/resources/js/src/sql.ts b/resources/js/src/sql.ts
index 10a10dc37c..6296e46a48 100644
--- a/resources/js/src/sql.ts
+++ b/resources/js/src/sql.ts
@@ -263,7 +263,7 @@ const insertQuery = function (queryType) {
setQuery('');
return;
- } else if (queryType === 'format') {
+ } else if (queryType === 'format' || queryType === 'formatSingleLine') {
if (window.codeMirrorEditor) {
$('#querymessage').html(window.Messages.strFormatting +
'
{% if codemirror_enable %}
+
{% endif %}
diff --git a/src/Controllers/Database/SqlFormatController.php b/src/Controllers/Database/SqlFormatController.php
index 0d985b3939..7aa4f80dbe 100644
--- a/src/Controllers/Database/SqlFormatController.php
+++ b/src/Controllers/Database/SqlFormatController.php
@@ -23,7 +23,11 @@ final class SqlFormatController implements InvocableController
{
/** @var string $query */
$query = $request->getParsedBodyParam('sql', '');
- $this->response->addJSON(['sql' => Formatter::format($query)]);
+ if ($request->getParsedBodyParam('formatSingleLine') === 'true') {
+ $this->response->addJSON(['sql' => Formatter::format($query, ['line_ending' => ' ', 'indentation' => ''])]);
+ } else {
+ $this->response->addJSON(['sql' => Formatter::format($query)]);
+ }
return $this->response->response();
}