Trivadis/plsql-formatter-settings

Wrong indentation in subqueries of with_clause in insert statements

Closed this issue · 0 comments

The formatting result of the following script

insert into t1
select object_type, count(*)
  from (
          select 'table' as object_type, table_name as object_name
            from user_tables
          union all
          select 'view', view_name
            from user_views
          union all
          select 'sequence', sequence_name
            from user_sequences
       )
 group by object_type;

insert into t2
with
   objects as (
      select 'table' as object_type, table_name as object_name
        from user_tables
      union all
      select 'view', view_name
        from user_views
      union all
      select 'sequence', sequence_name
        from user_sequences
   )
select object_type, count(*)
  from objects
 group by object_type;
/

insert into t3
with
   combined as (
      select object_type, count(*)
        from (
                select 'table' as object_type, table_name as object_name
                  from user_tables
                union all
                select 'view', view_name
                  from user_views
                union all
                select 'sequence', sequence_name
                  from user_sequences
             )
       group by object_type
   )
select *
  from combined;
/

looks like this:

insert into t1
select object_type, count(*)
  from (
select 'table' as object_type, table_name as object_name
  from user_tables
          union all
select 'view', view_name
  from user_views
          union all
          select 'sequence', sequence_name
            from user_sequences
       )
 group by object_type;

insert into t2
with
   objects as (
select 'table' as object_type, table_name as object_name
  from user_tables
      union all
select 'view', view_name
  from user_views
      union all
      select 'sequence', sequence_name
        from user_sequences
   )
select object_type, count(*)
  from objects
 group by object_type;
/

insert into t3
with
   combined as (
      select object_type, count(*)
        from (
select 'table' as object_type, table_name as object_name
  from user_tables
                union all
select 'view', view_name
  from user_views
                union all
                select 'sequence', sequence_name
                  from user_sequences
             )
       group by object_type
   )
select *
  from combined;
/

The indentations of the subqueries in the with clause are wrong. Expected is the original script.

The result looks good for the queries only (without insert).