SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[9.0.176 Pro] - Code Folding groups with CTE

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[9.0.176 Pro] - Code Folding groups with CTE
Author Message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post [9.0.176 Pro] - Code Folding groups with CTE Reply with quote


In the image above you can see that the code folding in SSMS 2016 (16.5) does not try and fold in the clustered index of the temp table above it into the CTE logic below it like it does in SQL Editor (64-bit).

I tried adding whitespace but that didn't remedy it. The only thing that seems to break that up is ending the create unique clustered index line with a semicolon.


Last edited by Mindflux on Mon Nov 14, 2016 9:41 pm; edited 1 time in total
Mon Nov 14, 2016 4:38 pm View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
Looking at another piece of code I have it seems it's not directly related to the CTE, FYI. But if I fold that 'CREATE UNIQUE' line up, it folds about 30 lines of code under it that it shouldn't be. A semicolon fixes that (but shouldn't be required?)

My FIRST 'CREATE UNIQUE' folds from line 42 all the way to 236. :(


It also seems INSERT INTO's aren't folded from the INSERT line (or the select) only areas where opening and closing parenthesis are wrapping columns and such. SSMS seems to be choosing where to fold a bit better.
Mon Nov 14, 2016 6:07 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7841

Post Reply with quote
I think that is caused by the current generic SQL code parsing implementation used for code folding. In some databases CREATE INDEX syntax supports WITH keywords. Without a semicolon the generic SQL code parser treats your CTE as a continuation of CREATE INDEX. I'm not sure if it can be fixed easily., but I will ask anyway
Tue Nov 15, 2016 10:42 am View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
SysOp wrote:
I think that is caused by the current generic SQL code parsing implementation used for code folding. In some databases CREATE INDEX syntax supports WITH keywords. Without a semicolon the generic SQL code parser treats your CTE as a continuation of CREATE INDEX. I'm not sure if it can be fixed easily., but I will ask anyway


Per my update above, even if I remove the CTE anything following a CREATE UNIQUE statement seems to get folded into that statement.

For instance, I have a "CREATE UNIQUE CLUSTERED INDEX" at line 52, at line 54 I have a few insert intos and some update statements. If I fold the "CREATE UNIQUE", the whole thing to line 232 folds with it.
Tue Nov 15, 2016 10:44 am View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
Also why does the code folding not fold at the start of the statement, all it wants to fold is my items wrapped in parens?
Tue Nov 15, 2016 10:46 am View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
Ah hah! it has something to do with my BEGIN CATCH / END CATCH causing the code folding to go sideways way above:

Code:

BEGIN CATCH
      DECLARE @ErrorMessage      NVARCHAR(4000)
             ,@ErrorSeverity     INT
             ,@ErrorState        INT;
      
      SELECT @ErrorMessage      = ERROR_MESSAGE()
            ,@ErrorSeverity     = ERROR_SEVERITY()
            ,@ErrorState        = ERROR_STATE();
      
      RAISERROR(@ErrorMessage ,@ErrorSeverity ,@ErrorState)
END CATCH


*Edit: More specifically the LAST semi-colon in the begin/catch.
Tue Nov 15, 2016 10:53 am View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
Video:

You can see when I add that semicolon a new folding line appears next to it. That line goes all the way up to line 52.

http://screencast.com/t/nl867WhG1g

So it appears to be have a common thread. The semicolon in the CTE ;WITH, and the semicolon in the begin catch statement (or semicolons in general)
Tue Nov 15, 2016 10:58 am View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 810
Country: United States

Post Reply with quote
Any notes from dev on why semicolon seems to throw the folding logic off? And why folding doesn't apply to the top level of the statement? Only seems to care about parens and semicolons?
Fri Nov 18, 2016 4:41 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7841

Post Reply with quote
Their response is that code folding is currently a generic implementation which isn't SQL dialect aware (database type). The way to improve it is to develop SQL dialect specific versions. Something they are planning to do.
Mon Nov 21, 2016 12:27 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.