Skip to content

Commit f5acece

Browse files
committed
Change how CREATE VIEW is formatted
Similarly to the recent CREATE TABLE change
1 parent 3f62841 commit f5acece

File tree

17 files changed

+25
-44
lines changed

17 files changed

+25
-44
lines changed

src/languages/bigquery/bigquery.formatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const reservedClauses = expandPhrases([
3030
'MERGE [INTO]',
3131
'WHEN [NOT] MATCHED [BY SOURCE | BY TARGET] [THEN]',
3232
'UPDATE SET',
33-
// Data definition, https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
34-
'CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]',
3533

3634
'CLUSTER BY',
3735
'FOR SYSTEM_TIME AS OF', // CREATE SNAPSHOT TABLE
@@ -42,7 +40,9 @@ const reservedClauses = expandPhrases([
4240

4341
const onelineClauses = expandPhrases([
4442
// - create:
43+
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
4544
'CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]',
45+
'CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]',
4646
// - update:
4747
'UPDATE',
4848
// - delete:

src/languages/db2/db2.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ const reservedClauses = expandPhrases([
3434
'WHEN [NOT] MATCHED [THEN]',
3535
'UPDATE SET',
3636
'INSERT',
37-
// Data definition
38-
'CREATE [OR REPLACE] VIEW',
3937
]);
4038

4139
const onelineClauses = expandPhrases([
4240
// - create:
4341
'CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]',
42+
'CREATE [OR REPLACE] VIEW',
4443
// - update:
4544
'UPDATE',
4645
'WHERE CURRENT OF',

src/languages/db2i/db2i.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ const reservedClauses = expandPhrases([
3535
'INSERT',
3636
// Data definition - table
3737
'FOR SYSTEM NAME',
38-
// Data definition - view
39-
'CREATE [OR REPLACE] [RECURSIVE] VIEW',
4038
]);
4139

4240
const onelineClauses = expandPhrases([
4341
// - create:
4442
'CREATE [OR REPLACE] TABLE',
43+
'CREATE [OR REPLACE] [RECURSIVE] VIEW',
4544
// - update:
4645
'UPDATE',
4746
'WHERE CURRENT OF',

src/languages/hive/hive.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ const reservedClauses = expandPhrases([
3939
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
4040
'LOAD DATA [LOCAL] INPATH',
4141
'[OVERWRITE] INTO TABLE',
42-
// Data definition
43-
'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]',
4442
]);
4543

4644
const onelineClauses = expandPhrases([
4745
// - create:
4846
'CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]',
47+
'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]',
4948
// - update:
5049
'UPDATE',
5150
// - delete:

src/languages/mariadb/mariadb.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ const reservedClauses = expandPhrases([
2626
'ON DUPLICATE KEY UPDATE',
2727
// - update:
2828
'SET',
29-
// Data definition
30-
'CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]',
3129
// other
3230
'RETURNING',
3331
]);
3432

3533
const onelineClauses = expandPhrases([
3634
// - create:
3735
'CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]',
36+
'CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]',
3837
// - update:
3938
'UPDATE [LOW_PRIORITY] [IGNORE]',
4039
// - delete:

src/languages/mysql/mysql.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ const reservedClauses = expandPhrases([
2626
'ON DUPLICATE KEY UPDATE',
2727
// - update:
2828
'SET',
29-
// Data definition
30-
'CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]',
3129
]);
3230

3331
const onelineClauses = expandPhrases([
3432
// - create:
3533
'CREATE [TEMPORARY] TABLE [IF NOT EXISTS]',
34+
'CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]',
3635
// - update:
3736
'UPDATE [LOW_PRIORITY] [IGNORE]',
3837
// - delete:

src/languages/plsql/plsql.formatter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ const reservedClauses = expandPhrases([
2828
'MERGE [INTO]',
2929
'WHEN [NOT] MATCHED [THEN]',
3030
'UPDATE SET',
31-
// Data definition
32-
'CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW',
33-
'CREATE MATERIALIZED VIEW',
3431
// other
3532
'RETURNING',
3633
]);
3734

3835
const onelineClauses = expandPhrases([
3936
// - create:
4037
'CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE',
38+
'CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW',
39+
'CREATE MATERIALIZED VIEW',
4140
// - update:
4241
'UPDATE [ONLY]',
4342
// - delete:

src/languages/postgresql/postgresql.formatter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ const reservedClauses = expandPhrases([
2525
'VALUES',
2626
// - update:
2727
'SET',
28-
// Data definition
29-
'CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW',
30-
'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]',
3128
// other
3229
'RETURNING',
3330
]);
3431

3532
const onelineClauses = expandPhrases([
3633
// - create
3734
'CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]',
35+
'CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW',
36+
'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]',
3837
// - update:
3938
'UPDATE [ONLY]',
4039
'WHERE CURRENT OF',

src/languages/redshift/redshift.formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ const reservedClauses = expandPhrases([
2222
'VALUES',
2323
// - update:
2424
'SET',
25-
// Data definition
26-
'CREATE [OR REPLACE | MATERIALIZED] VIEW',
2725
]);
2826

2927
const onelineClauses = expandPhrases([
3028
// - create:
3129
'CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]',
30+
'CREATE [OR REPLACE | MATERIALIZED] VIEW',
3231
// - update:
3332
'UPDATE',
3433
// - delete:

src/languages/singlestoredb/singlestoredb.formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const reservedClauses = expandPhrases([
2626
// - update:
2727
'SET',
2828
// Data definition
29-
'CREATE VIEW',
3029
'CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]',
3130
'CREATE [OR REPLACE] [EXTERNAL] FUNCTION',
3231
]);
3332

3433
const onelineClauses = expandPhrases([
3534
// - create:
3635
'CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]',
36+
'CREATE VIEW',
3737
// - update:
3838
'UPDATE',
3939
// - delete:

0 commit comments

Comments
 (0)