Toad World® Forums

Formatting Issue


#1

When you format a select statement with an order or group by, it always indents the “select” keyword. VERY annoying.


#2

Hi Joe,

The SELECT indents because it has to move right a little bit to align with the ORDER BY from right hand side. There’s an option to select right aligned or left aligned for the DML statements. By default it’s right aligned so you find that the SELECT always indents when there’s an order by or group by. You can change the option to left aligned and it may help. See attached images.

Thanks,
Vincent
left_align.jpeg


#3

Hi Joe,

The SELECT indents because it has to move right a little bit to align with the ORDER BY from right hand side. There’s an option to select right aligned or left aligned for the DML statements. By default it’s right aligned so you find that the SELECT always indents when there’s an order by or group by. You can change the option to left aligned and it may help. See attached images.

Thanks,
Vincent
right_align.jpeg


#4

Well, that’s just silly. I guess I didn’t realize just how lousy the two options are. either you get no indentation at all or, you get right justified indentation. Oh, and that doesn’t always work as you describe it unless “rollup” isn’t considered a keyword because it doesn’t right justify to the rollup.

OK, then my comment is now. Please add another option that will indent the keywords under the “primary” command to a set column.

In actuality, the whole formatter needs some help with the options. I don’t think certain commands (e.g. case) are even supported correctly.

Thanks,

Jet


#5

Hi Jet,

I have forwarded your comment to the formatter team. We’re working on this and will keep you posted.

Thanks,
Vincent


#6

Hi Jet,

First, the “rollup” is not considered to be aligned because it’s a function rather than a command. The option says “Keywords RIGHT aligned”. The “keywords” is kind of misleading I think we may change it.

By “add another option that will indent the keywords under the “primary” command to a set column”, do you mean you want to get the result like below?

SELECT *
FROM DUAL
WHERE dummy <> ‘’
ORDER BY dummy;
or
SELECT *
FROM DUAL
WHERE dummy <> ‘’
ORDER BY dummy;

We want to know your exact requirement so that we can consider the implementation.

thanks,
Vincent


#7

Either of these options would be preferable and maybe that’s what you should change the option to mean.

I think the critical part of this is that it’s easy to identify the statement that’s being run. So, having “Select” stand out with the indenting is good. Either ordering of the rest of the key words is fine. I would probably use the left justified one (the second one).

Thanks,

Jet
p.s. if you guys are serious about improving the formatter, let me know and I’ll give you more feedback on how it should work.


#8

Hi Jet,

Thanks a lot for your comments. We will intrduce a new option to indent the other commands after “SELECT” and keep “SELECT” staying left. This option accepts integer value to set how many columns will the other commands indent. I will let you know once we include this into SQL Nav :).

Yes we surely want to make our formatter better and better. We really appreciate your feedbacks. Please feel free to bring them up anytime you want to.

Thanks,
Vincent