Skip to content

Commit

Permalink
Format GO on a separate line in Transact-SQL
Browse files Browse the repository at this point in the history
Fixes #814
  • Loading branch information
nene committed Dec 23, 2024
1 parent c71cf6f commit df4c535
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/languages/transactsql/transactsql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const tabularOnelineClauses = expandPhrases([
'ALTER COLUMN',
// - truncate:
'TRUNCATE TABLE',
// indexes
'CREATE [UNIQUE] [CLUSTERED] INDEX',
// other statements
'GO',
// https://docs.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver15
'ADD SENSITIVITY CLASSIFICATION',
'ADD SIGNATURE',
Expand Down
13 changes: 13 additions & 0 deletions test/transactsql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,17 @@ describe('TransactSqlFormatter', () => {
tbl OUTPUT $action AS act;
`);
});

// Issue #814
it('formats GO on a separate line', () => {
expect(format(`CREATE VIEW foo AS SELECT * FROM tbl GO CREATE INDEX bar`)).toBe(dedent`
CREATE VIEW foo AS
SELECT
*
FROM
tbl
GO
CREATE INDEX bar
`);
});
});

0 comments on commit df4c535

Please sign in to comment.