TaoK / PoorMansTSqlFormatter

A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
GNU Affero General Public License v3.0
964 stars 267 forks source link

TSQL: wrong indent for IF ... THROW if BEGIN...END is not used #266

Open aisbergde opened 3 years ago

aisbergde commented 3 years ago

Ty to format some TSQL containing IF and THROW, you get this wrong result with unwanted indents

IF @persistence_name_suffix IS NULL THROW 51001
 , '@persistence_name_suffix is null'
 , 1;
 IF @source_RepoObject_guid IS NULL
  AND @persistence_RepoObject_guid IS NULL THROW 51002
  , '@source_RepoObject_guid is null and @persistence_RepoObject_guid is null'
  , 1;
  IF NOT @persistence_RepoObject_guid IS NULL
   AND @source_RepoObject_guid IS NULL
  BEGIN
   SELECT 1
  END

this is the documentation for THROW https://docs.microsoft.com/de-de/sql/t-sql/language-elements/throw-transact-sql?view=sql-server-ver15

A line break before THROW would be fine