Skip to content

Condition with logical structure

Tako Lee edited this page Mar 7, 2014 · 3 revisions

Switch parentheses, which structure interlaced logical expressions into a new line. Turn this SQL

Option: fmt084_condition_with_logical_structure = false, type: TFmtBoolean.

SELECT f 
FROM   t 
WHERE 
  test1 IN ( 'Group1', 'Group2', 'Group3', 'Group4' ) 
  AND ( test2 IS NULL 
         OR test2 NOT IN ( 'Group3', 'Group5' ) 
         OR ( ( test2 IN ( 'Group3', 'Group4' ) 
                AND test3 <> 10 ) 
              AND NOT ( test2 IN ( 'Group6', 'Group7' ) 
                        AND test3 = 20 ) ) ) 
  AND test4 NOT IN ( 7654321, 1234567 ) 

into

Option: fmt084_condition_with_logical_structure = true, type: TFmtBoolean.

SELECT f 
FROM   t 
WHERE 
  test1 IN ( 'Group1', 'Group2', 'Group3', 'Group4' ) 
  AND 
  ( 
    test2 IS NULL 
     OR test2 NOT IN ( 'Group3', 'Group5' ) 
     OR 
    ( 
      ( 
        test2 IN ( 'Group3', 'Group4' ) 
        AND test3 <> 10 
       ) 
      AND NOT 
          ( 
            test2 IN ( 'Group6', 'Group7' ) 
            AND test3 = 20 
           ) 
     ) 
   ) 
  AND test4 NOT IN ( 7654321, 1234567 ) 
Clone this wiki locally