Search code examples
sqlpostgresqlformattingjetbrains-idedatagrip

How to use DataGrip SQL formatter with compound WHERE clause


Which configuration can I set to get each clause of a WHERE statement to start on a new line? For example:

-- bad
select *
from table
where a = 1 and b = 2
-- good
select *
from table
where a = 1
  and b = 2

Solution

  • In order to get each part of AND or OR condition on the next line, just set the following:

    Queries / WHERE and HAVING clauses / Wrap elements ⟶ Chop