Skip to content

Incorrect SQL Formatting with Directives #353

@xterao

Description

@xterao

Describe the bug

  • In some cases, blocks immediately following conditional or loop directives are not line-broken correctly.

  • The indentation of keyword groups enclosed by directives can become misaligned or incorrect.

Expected behavior
Adjusted the formatting logic to ensure correct handling of block combinations.

Improved directive-aware formatting to apply proper line breaks and indentation based on the position of surrounding blocks.

Also,Add spacing rules to prevent a space from being inserted between a variable directive and a following column name.

Sample
Before:

            select
              /*%expand*/*
            from
              employee
            where
            /*%if min != null */
              age >= /* min */10
            /*%end */

After:

            SELECT /*%expand*/*
              FROM employee
             WHERE
                   /*%if min != null */               age >= /* min */10
                   /*%end */

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions