Parenthetical Indentation within a CASE expression

a.higginsa.higgins Posts: 90 Bronze 2
edited October 11, 2016 2:06PM in SQL Prompt
Most of the new indentation options are awesome, but I've seen some strange behavior with parentheses. In the query below, shouldn't the 'IN' list be indented from the CASE?
SELECT Field = CASE
					WHEN 'LongStringToEnsureThisDoesNotStayOnOneLine' IN
	(
		'SomeOtherRandomLongString'
	   ,'YetOtherRandomLongString'
	)
					THEN 'WhyAreTheseParenthesesWrong?'
					ELSE 'RedGateIsStillAwesomeThough'
			   END

Currently running Version 7.3.0.598

Comments

  • Aaron LAaron L Posts: 596 New member
    Hi a.higgins,

    Thanks for the script! :) We're looking into this now and should hopefully have a fix in the next beta build.

    Thanks,
    Aaron.
  • a.higginsa.higgins Posts: 90 Bronze 2
    This solves the IN () indentation, but there still seems to be some issues with other types of parenthetical indentations: for example
    SELECT Field = CASE
    					WHEN
    	(
    		'LongStringToEnsureThisDoesNotStayOnOneLine' LIKE '%xya%' OR
    		'SomeOtherRandomLongString' LIKE '%qwe%' OR
    		'YetOtherRandomLongString' LIKE '%aslpha%'
    	) AND
    	'WhyAreTheseParenthesesWrong?' IS NOT NULL
    					THEN 'Help'
    					ELSE 'All Fixed Now'
    			   END
    
  • a.higginsa.higgins Posts: 90 Bronze 2
    Another example, though this one isn't within a CASE:
    SELECT
    	SimpleField	 = 'xyz'
       ,AnotherField =
       ( -- I'd expect this to be indented to align with the 'xyz' string out past the equals sign
    	   SELECT TOP 1
    		   t.TABLE_NAME
    	   FROM INFORMATION_SCHEMA.TABLES t
       )
    
Sign In or Register to comment.