clarkyu2016 / sql-beautify

VS Code extension that beautifies SQL(HQL).
MIT License
60 stars 21 forks source link

Comments directly after CASE cause the rest of the code to be commented out #23

Open jhomiak opened 2 years ago

jhomiak commented 2 years ago

Comments directly after CASE cause the rest of the code to be commented out. In addition, it would be nice if the CASE WHEN THEN ELSE END statements we're able to be on their own line and indented, instead of all on the same line. It can cause huge blocks of unreadable code.

Version: 0.2.8 (2021/11/01)

------ Before
TestCase = CASE
-- Handles some logic
WHEN 1 = 1
THEN 'True'
ELSE 'False'
END

------ After
TestCase = CASE
-- Handles some logic WHEN 1 = 1 THEN 'True' ELSE 'False' END
clarkyu2016 commented 2 years ago

Hi, jsh121988! Thanks for your issue and sorry for late reply. Sql with comments is a big problem when I developed this plugin and it still can not satisfy all users' habits of comments.

In my opinion, in this "case when" case, it is more reasonable to put comments after each "then XXX" or put comments after "END AS xxx". So I designed to start a new line when meeting "THEN"/"ELSE"/"END". It can work like this:

------ Before SELECT CASE WHEN 1 = 1 THEN 'True' -- Handles some logic ELSE 'False' -- Handles some logic2 END AS TABLE FROM TABLE

------ After select case when 1 = 1 then 'True' -- Handles some logic else 'False' -- Handles some logic end as TABLE from TABLE

But I will still try to fix this comments situation.