 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[12.0.167 BETA] - Formatting USE in SQL Server |
|
The formatter does something unexpected when it meets a USE statement. I've got this in the editor:
 |
 |
USE [jack_of_all_trades_master_of_none];
SELECT 1 AS [a];
SELECT 2 AS [b];
|
and it is turned into this:
 |
 |
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:
 |
 |
USE [jack_of_all_trades_master_none] ;
SELECT 1 AS [a];
SELECT 2 AS [b];
|
it will be formatted to:
 |
 |
USE [jack_of_all_trades_master_none] ;
SELECT 1 AS [a];
SELECT 2 AS [b];
|
or this
 |
 |
USE [jack_of_all_trades_master_none]
;
SELECT 1 AS [a];
SELECT 2 AS [b];
|
to this:
 |
 |
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
|
|
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
|
|
|