Trivadis/plsql-formatter-settings

Wrong indentation of case expression in right-aligned clause

PhilippSalvisberg opened this issue · 0 comments

Input/expected output with default settings:

select obj_type(
          owner       => o.owner,
          object_type => o.object_type,
          object_name => o.object_name
       )
  from dba_objects o
 where o.owner = coalesce(in_obj.owner, in_parse_user, 'PUBLIC')
   and o.object_name = in_obj.object_name
 order by case o.owner
             when in_obj.owner then
                1
             when in_parse_user then
                2
             else
                3
          end,
       case o.object_type
          when in_obj.object_type then
             1
          when 'SYNONYM' then
             3
          else
             2
       end;

formatter output:

select obj_type(
          owner       => o.owner,
          object_type => o.object_type,
          object_name => o.object_name
       )
  from dba_objects o
 where o.owner = coalesce(in_obj.owner, in_parse_user, 'PUBLIC')
   and o.object_name = in_obj.object_name
 order by case o.owner
            when in_obj.owner then
               1
            when in_parse_user then
               2
            else
               3
         end,
       case o.object_type
          when in_obj.object_type then
             1
          when 'SYNONYM' then
             3
          else
             2
       end;

Use parenthesis as workaround:

select obj_type(
          owner       => o.owner,
          object_type => o.object_type,
          object_name => o.object_name
       )
  from dba_objects o
 where o.owner = coalesce(in_obj.owner, in_parse_user, 'PUBLIC')
   and o.object_name = in_obj.object_name
 order by (
       case o.owner
          when in_obj.owner then
             1
          when in_parse_user then
             2
          else
             3
       end),
       case o.object_type
          when in_obj.object_type then
             1
          when 'SYNONYM' then
             3
          else
             2
       end;