Skip to content

Commit df4c535

Browse files
committed
Format GO on a separate line in Transact-SQL
Fixes #814
1 parent c71cf6f commit df4c535

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/languages/transactsql/transactsql.formatter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const tabularOnelineClauses = expandPhrases([
5353
'ALTER COLUMN',
5454
// - truncate:
5555
'TRUNCATE TABLE',
56+
// indexes
57+
'CREATE [UNIQUE] [CLUSTERED] INDEX',
58+
// other statements
59+
'GO',
5660
// https://docs.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver15
5761
'ADD SENSITIVITY CLASSIFICATION',
5862
'ADD SIGNATURE',

test/transactsql.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,17 @@ describe('TransactSqlFormatter', () => {
205205
tbl OUTPUT $action AS act;
206206
`);
207207
});
208+
209+
// Issue #814
210+
it('formats GO on a separate line', () => {
211+
expect(format(`CREATE VIEW foo AS SELECT * FROM tbl GO CREATE INDEX bar`)).toBe(dedent`
212+
CREATE VIEW foo AS
213+
SELECT
214+
*
215+
FROM
216+
tbl
217+
GO
218+
CREATE INDEX bar
219+
`);
220+
});
208221
});

0 commit comments

Comments
 (0)