Skip to content

Improve SQL Beautify: use sql-formatter and support bind variables#2071

Merged
GCHQDeveloper581 merged 7 commits into
gchq:masterfrom
aby-jo:fix-sql-beautify-upsert
Mar 2, 2026
Merged

Improve SQL Beautify: use sql-formatter and support bind variables#2071
GCHQDeveloper581 merged 7 commits into
gchq:masterfrom
aby-jo:fix-sql-beautify-upsert

Conversation

@aby-jo

@aby-jo aby-jo commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Fixes #2067

Summary

  • Replaces vkbeautify with sql-formatter for improved SQL formatting.
  • Adds support for bind variables (e.g., :Bind1) by replacing them with placeholders during formatting.
  • Defaults to the mysql dialect for broad compatibility.
  • Supports indentation with tabs or spaces via UI argument.

Example

Input:

INSERT INTO Table1 SELECT * FROM (SELECT :Bind1 as Field1) as new_data ON DUPLICATE KEY UPDATE Field1 = new_data.Field1;

Output

INSERT INTO
 Table1
SELECT
 *
FROM
 (
  SELECT
   :Bind1 as Field1
 ) as new_data
ON DUPLICATE KEY UPDATE
 Field1 = new_data.Field1;

@CLAassistant

CLAassistant commented Jun 24, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@GCHQDeveloper581
GCHQDeveloper581 self-requested a review March 2, 2026 12:40
@GCHQDeveloper581
GCHQDeveloper581 merged commit 813a543 into gchq:master Mar 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Beautify operation cannot beautify upsert commands

4 participants