SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[12.0.167 BETA] - Formatting USE in SQL Server

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[12.0.167 BETA] - Formatting USE in SQL Server
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post [12.0.167 BETA] - Formatting USE in SQL Server Reply with quote
The formatter does something unexpected when it meets a USE statement. I've got this in the editor:
Code:

USE [jack_of_all_trades_master_of_none];
                                       
SELECT 1 AS [a];
SELECT 2 AS [b];


and it is turned into this:
Code:

USE [jack_of_all_trades_master_none];
                                   
                                    SELECT 1 AS [a];
                                    SELECT 2 AS [b];


The lines following the USE statement line are always indented on the same column the statement closing ';' is located for the USE statement and that closing ';' won't be moved closer to the statement it closes, so when I have this:
Code:

USE [jack_of_all_trades_master_none]      ;
                                       
SELECT 1 AS [a];
SELECT 2 AS [b];


it will be formatted to:
Code:

USE [jack_of_all_trades_master_none]    ;
                                       
                                        SELECT 1 AS [a];
                                        SELECT 2 AS [b];


or this
Code:

USE [jack_of_all_trades_master_none]

    ;
   
SELECT 1 AS [a];
SELECT 2 AS [b];


to this:
Code:

USE [jack_of_all_trades_master_none]

    ;
   
    SELECT 1 AS [a];
    SELECT 2 AS [b];


I guess this bug(?) was always there but the previous versions formatted my USE statements by moving the closing ';' to the first column of the next line (which I found funny but never bothered me), hence I never noticed.

I have no rules defined for USE.
Sun Oct 03, 2021 2:55 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
Thank you. It certainly looks like a bug to me. I created new ticket #SA0042122 for that issue.
Sun Oct 03, 2021 8:44 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
We are unable to reproduce this issue with default formatting rules. Maybe there is a custom rule setup which is somewhat interfering and leading to this side effect?
Fri Oct 08, 2021 8:01 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
It could be, but which one? I have only one rule that starts with a semicolon (the one for WITH) and none for USE. It breaks immediately after the USE and before the SELECT and there were no more lines beyond those three.
Fri Oct 08, 2021 9:50 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
May i ask to try disabling the WITH rule for a minute, try formatting with that disabled, and then reenable it?
Fri Oct 08, 2021 10:40 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
You were right. It wasn't the WITH rule (I've disabled that earlier) but another one. I disabled all of them and then started re-enabling them one by one. It took the better part of an hour but it turned out that I have a rule for THROW (I don't even remember creating it) that also has a semicolon as the first character in the rule. I removed that starting semicolon from both rules and now everything returned to normal (except that I no longer get my USEs separated from their closing semicolon).
Sat Oct 09, 2021 9:29 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
Thank you. This is very helpful. I'm sure it's an unintended side effect. But it could be better. I would think that ";" symbols shouldn't be treated as regular pattern based anchors, but not sure if that behavior can be improved easily.
Sat Oct 09, 2021 11:56 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Yes, well, now that it's confirmed, this might serve as a warning for others to not start rules with ";".
Sat Oct 09, 2021 4:06 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.