-
Notifications
You must be signed in to change notification settings - Fork 0
Labels
Description
Describe the bug
When an EXISTS clause is used inside a conditional directive following a WHERE clause, the subquery is formatted incorrectly, causing unintended line breaks.
Example (current behavior):
WHERE
/*%if filterByHighPerformers */
EXISTS
( SELECT 1
FROM performance_reviews pr
WHERE pr.employee_id = e.id
/*%if reviewPeriod != null */
AND pr.review_date BETWEEN /* reviewPeriod.startDate */'2023-01-01' AND /* reviewPeriod.endDate */'2023-12-31'
/*%end*/
/*%if minScore != null */
AND pr.performance_score >= /* minScore */4.0
/*%end*/ )
/*%else*/The formatter forces a line break after the EXISTS keyword, separating it unnecessarily from the following parenthesis and subquery. This makes the SQL less readable and inconsistent compared to standard formatting expectations.
Expected behavior
The EXISTS keyword should remain on the same line as the opening parenthesis of the subquery, e.g.:
WHERE
/*%if filterByHighPerformers */
EXISTS ( SELECT 1
FROM performance_reviews pr
WHERE pr.employee_id = e.id
/*%if reviewPeriod != null */
AND pr.review_date BETWEEN /* reviewPeriod.startDate */'2023-01-01' AND /* reviewPeriod.endDate */'2023-12-31'
/*%end*/
/*%if minScore != null */
AND pr.performance_score >= /* minScore */4.0
/*%end*/ )
/*%else*/Desktop :
- IDEA Version : 2024.3.6
- Doma Tools Version : 2.1.1