Collapse CASE statements

a.higginsa.higgins Posts: 90 Bronze 2
edited August 30, 2016 12:59PM in SQL Prompt
The "Collapse CASE statements shorter than N characters" option appears to conflict with the Lists --> List items --> "Place first item on new line" option, when the first expression in a SELECT statement is a CASE expression.

When I have "Place first item on new line" set to Always and "Collapse CASE statements" unchecked, my code looks like the following:
SELECT
	CASE
		WHEN 1 = 1
		THEN 1 END AS x
   ,1 AS y

SELECT
	0 AS w
   ,CASE
		WHEN 1 = 1
		THEN 1 END AS x
   ,1 AS y

When I check "Collapse CASE statements", it turns into this:
SELECT CASE WHEN 1 = 1 THEN 1 END AS x
   ,1 AS y

SELECT
	0 AS w
   ,CASE WHEN 1 = 1 THEN 1 END AS x
   ,1 AS y

Notice that the query with the CASE expression first goes back and forth between respecting the First Line option and ignoring it.


Closing nitpick: technically it's a CASE expression, not a CASE statement...

Comments

Sign In or Register to comment.