Toad World® Forums

Formatter issues. "Keywords RIGHT aligned"


#1

Formatter Options-Statements…-DML satements- Keywords RIGHT aligned" is ignored when choosing Compact “DML Statement RHS Alignment”.

With Fixed option “DML Statement RHS Alignment” works normally with “Align right hand side at” 7. And over 7 SELECTs and UPDATEs move to right to meet the alignent but DELETEs and INSERTs don’t. (Probably because they are actually INERT INTOs and DELETE FROMs). Still it’s very confusing if some internal alignment will mess with indenting of a full statement - the general indenting (“General - Indenting”).

Formatter options:5.126.0
Formatter Engine: 5.126.903.23002

Marko


#2

Hi Marko,

  1. Formatter Options-Statements…-DML statements- Keywords RIGHT aligned" is ignored when choosing Compact “DML Statement RHS Alignment”.

I can see the problem too. The result should be:
SELECT col1, col2
FROM my_tab;

  1. With Fixed option “DML Statement RHS Alignment” works normally with “Align right hand side at” 7. And over 7 SELECTs and UPDATEs move to right to meet the alignment but DELETEs and INSERTs don’t. (Probably because they are actually INERT INTOs and DELETE FROMs).

DELETEs and INSERTs work the same actually. “Align right hand side at” n means the identifiers following DML keywords will starts at least from column n, and the DML keywords will align left or right according to the option in “DML Statement LHS Alignment”. You didn’t see the DELETEs and INSERTs alignment changing because the value you set was not bigger than the right hand side identifier existing column value. (You’re right. Because the INTO and FROM next to INSERT and DELETE force the right hand side identifiers start from a little bit far right so a value less than 12 could not let you see the valid change).

  1. Still it’s very confusing if some internal alignment will mess with indenting of a full statement - the general indenting (“General - Indenting”).>> Thanks for pointing this out. I agree with you. At this point, I think when we select “Keywords RIGHT alignment” combining with “Fixed” in DML Statement RHS Alignment, we should still put the DML keywords at the beginning of each line (after indenting if needed) and just align them RIGHT with the longest keyword(s). Thus, the indenting value only works for the longest keyword(s) at the beginning of line. e.g.:
    BEGIN SELECT col1, col2
    FROM tab;

    INSERT INTO tab
    VALUES (1, 2);

       **UPDATE**    tab
         SET    col1 = 1, col2 = 2
       **WHERE**    col1 < 1;
    

END;

I will forward this thread to Andre who is working on all the formatter functionalities. I would like to know what we can get from him as well :).

Thanks,
Vincent


#3

The linebreaks were broken. I attach an image of the code.
alignment_indenting.jpeg