Skip to content

Incorrect Line Break When Column Name Matches Function Name After Conditional Loop Directive #423

@xterao

Description

@xterao

Describe the bug
When a column name matches a PostgreSQL function name and is used immediately after a conditional loop directive, the formatter incorrectly introduces a line break in the condition.

Example (current behavior):

SELECT /*%expand*/
  *
  FROM employee
 WHERE
       /*%for age : ages */
       age = /* age */30
         /*%if age_has_next */
         /*# "or" */
         /*%end */
       /*%end */

Problem
Here, because age matches the PostgreSQL function age(), it is incorrectly treated as a keyword block. As a result, the = operator is pushed to a new line.

Additionally, if the column name is enclosed in escape quotes, the indentation of the entire loop directive block is lost and unnecessary spaces are introduced:

SELECT /*%expand*/
  *
  FROM employee
 WHERE
 /*%for age : ages */
 "age "= /* age */30
   /*%if age_has_next */
   /*# "or" */
   /*%end */
 /*%end */

Expected behavior

  • Words that are not treated as functions in other databases should be handled as column names without introducing unwanted line breaks.
  • When the element immediately following a conditional loop directive is enclosed in escape quotes, it should be indented properly without extra spaces.

Desktop :

  • IDEA Version: 2024.3.6
  • Doma Tools Version :2.1.2

Relational
#399

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions