List "new line" behaviour not consistent with TOP operator

a.higginsa.higgins Posts: 90 Bronze 2
edited September 16, 2016 9:02AM in SQL Prompt
Under Global --> Lists --> List Items, I have the "Place first item on new line" option set to "if there are subsequent items" (note: brief test shows the same issue applies when this is set to "always").

With a normal multi-column query, this works fine:
SELECT
	1 AS x -- this is nice
   ,2 AS y
   ,3 AS z

However, if I include the TOP operator, this breaks:
SELECT TOP 1 1 AS x -- wrong spot!! Arrgh!
   ,2 AS y
   ,3 AS z

I would expect the List items setting to work consistently for columns, regardless of the presence or absence of the TOP operator:
  SELECT TOP 1
	1 AS x -- yes yes yes
   ,2 AS y
   ,3 AS z

Comments

  • For fun, I just tried the 'DISTINCT' keyword and it works fine:
    SELECT DISTINCT
    	1 AS x -- yes yes yes
       ,2 AS y
       ,3 AS z
    
  • Hi a.higgins,

    The top clause has caused us quite a few problems. We'll look into getting this sorted.

    It is possible to get this behaviour you want by setting the following option:

    WuczfWd.png

    This won't keep it one line if there are multiple items, but you could combine this with the "Collapse statements shorter than x characters" option.

    If this doesn't work for you, I'll take a look to see if the options could be reworked.

    Best regards,

    David
Sign In or Register to comment.