Skip to content

feat(formatter): improve Watcom SQL formatting rules#5

Merged
MayerTim merged 19 commits into
mainfrom
feat/improve-sql-formatting-rules
Jun 10, 2026
Merged

feat(formatter): improve Watcom SQL formatting rules#5
MayerTim merged 19 commits into
mainfrom
feat/improve-sql-formatting-rules

Conversation

@MayerTim

Copy link
Copy Markdown
Owner

Summary

This PR improves SQLovely’s Watcom SQL formatter and syntax support with a broad set of formatting, metadata, highlighting, and safety fixes.

Changes

  • Normalize compact procedural IF ... THEN ... END IF statements.
  • Split parenthesized Watcom argument and declaration lists more consistently.
  • Keep UNION ALL on separate lines.
  • Preserve Watcom scalar IF ... THEN ... ELSE ... ENDIF expressions.
  • Split common query clauses such as SELECT, FROM, WHERE, JOIN, ON, ORDER BY, and related continuations.
  • Format Watcom cursor FOR ... CURSOR FOR ... DO ... END FOR loops.
  • Format Watcom CASE ... WHEN ... THEN ... ELSE ... END expressions.
  • Highlight quoted Watcom built-in function calls such as "isnull"(, "string"(, and "date"(.
  • Format Watcom exception handlers.
  • Support additional legacy metadata aliases and short date normalization.
  • Add formatter safety guards for large SQL documents.
  • Fix nested block-ending indentation edge cases.
  • Fix same-line block indentation accounting.
  • Fix ELSEIF branch indentation.
  • Preserve ORDER BY IF-expression separators.
  • Clean up statement continuations, arithmetic spacing, comma spacing, and DDL closing parentheses.

Notes

This PR is focused on stabilizing formatter behavior for real Watcom SQL exports and generated database scripts. It also adds safeguards to avoid running expensive formatting passes on very large SQL documents.

Testing

  • Ran the SQLovely test suite successfully after each step.
  • Added regression coverage for the newly supported formatter, metadata, syntax-highlighting, and safety-guard behavior.

@MayerTim MayerTim merged commit 310e816 into main Jun 10, 2026
1 check passed
@MayerTim MayerTim deleted the feat/improve-sql-formatting-rules branch June 10, 2026 09:29
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.

1 participant