Skip to main content

AND/OR position

andOrPosition decides which side of a line break the and or or goes on, once a boolean chain in where, having or join ... on is too wide for its line. before puts the operator at the head of the condition it introduces; after puts it at the tail of the condition before.

Default: before. Each line then starts with the operator that joins it to the chain, so the shape of the condition reads down the left margin, and an or among ands is visible where it matters.

after is for a project whose existing SQL ends its lines with the operator. Set it where that shape is already in place and the diff is not wanted.

The option is invisible until a chain breaks. A chain that fits its line stays on it under either value, so where the break falls is maxLineWidth's decision, and only the side of the operator is this option's.

The same WHERE, both settings​

select a, b from customers where status = 'active' and region = 'US' and created_at > '2024-01-01'
select a, b
from customers
where
    status = 'active'
    and region = 'US'
    and created_at > '2024-01-01'
select a, b from customers where status = 'active' and region = 'US' and created_at > '2024-01-01'
select a, b
from customers
where
    status = 'active' and
    region = 'US' and
    created_at > '2024-01-01'

An and/or inside a case when condition stays on one line under either setting: the CASE decides the shape of its own branches, and a when broken into three lines of conditions hides its then.