prettier-plugin-sql-cst 0.11.1 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/syntax/alter_action.d.ts +3 -0
- package/dist/syntax/alter_action.js +149 -0
- package/dist/syntax/alter_table.d.ts +2 -2
- package/dist/syntax/alter_table.js +9 -45
- package/dist/syntax/constraint.js +8 -5
- package/dist/syntax/create_table.js +4 -8
- package/dist/syntax/dialects/postgresql.js +4 -1
- package/dist/syntax/dialects/sqlite.js +0 -1
- package/dist/syntax/index.js +48 -2
- package/dist/syntax/schema.js +15 -7
- package/dist/syntax/sequence.d.ts +3 -0
- package/dist/syntax/sequence.js +46 -0
- package/dist/syntax/transformMap.js +3 -1
- package/dist/syntax/truncate.js +1 -5
- package/dist/syntax/view.d.ts +2 -2
- package/dist/syntax/view.js +18 -7
- package/dist/transform/canonicKeywords.js +2 -2
- package/package.json +3 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alterActionMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.alterActionMap = {
|
|
6
|
+
alter_action_rename: function (print) { return print.spaced(["renameKw", "newName"]); },
|
|
7
|
+
alter_action_rename_column: function (print) {
|
|
8
|
+
return print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]);
|
|
9
|
+
},
|
|
10
|
+
alter_action_add_column: function (print) {
|
|
11
|
+
return print.spaced(["addKw", "ifNotExistsKw", "column"]);
|
|
12
|
+
},
|
|
13
|
+
alter_action_drop_column: function (print) {
|
|
14
|
+
return print.spaced(["dropKw", "ifExistsKw", "column", "behaviorKw"]);
|
|
15
|
+
},
|
|
16
|
+
alter_action_set_bigquery_options: function (print) {
|
|
17
|
+
return print.spaced(["setKw", "options"]);
|
|
18
|
+
},
|
|
19
|
+
alter_action_set_default_collate: function (print) {
|
|
20
|
+
return print.spaced(["setDefaultCollateKw", "collation"]);
|
|
21
|
+
},
|
|
22
|
+
alter_action_add_constraint: function (print) {
|
|
23
|
+
return print.spaced(["addKw", "name", "constraint", "modifiers"]);
|
|
24
|
+
},
|
|
25
|
+
alter_action_add_constraint_constraint_name: function (print) {
|
|
26
|
+
return print.spaced(["constraintKw", "ifNotExistsKw", "name"]);
|
|
27
|
+
},
|
|
28
|
+
alter_action_drop_constraint: function (print) {
|
|
29
|
+
return print.spaced([
|
|
30
|
+
"dropConstraintKw",
|
|
31
|
+
"ifExistsKw",
|
|
32
|
+
"constraint",
|
|
33
|
+
"behaviorKw",
|
|
34
|
+
]);
|
|
35
|
+
},
|
|
36
|
+
alter_action_drop_primary_key: function (print) {
|
|
37
|
+
return print.spaced(["dropPrimaryKeyKw", "ifExistsKw"]);
|
|
38
|
+
},
|
|
39
|
+
alter_action_alter_constraint: function (print) {
|
|
40
|
+
return print.spaced(["alterConstraintKw", "constraint", "modifiers"]);
|
|
41
|
+
},
|
|
42
|
+
alter_action_rename_constraint: function (print) {
|
|
43
|
+
return print.spaced(["renameConstraintKw", "oldName", "toKw", "newName"]);
|
|
44
|
+
},
|
|
45
|
+
alter_action_validate_constraint: function (print) {
|
|
46
|
+
return print.spaced(["validateConstraintKw", "constraint"]);
|
|
47
|
+
},
|
|
48
|
+
alter_action_set_visible: function (print) { return print.spaced("setVisibleKw"); },
|
|
49
|
+
alter_action_set_invisible: function (print) { return print.spaced("setInvisibleKw"); },
|
|
50
|
+
alter_action_set_tablespace: function (print) {
|
|
51
|
+
return print.spaced(["setTablespaceKw", "tablespace", "nowaitKw"]);
|
|
52
|
+
},
|
|
53
|
+
alter_action_set_schema: function (print) { return print.spaced(["setSchemaKw", "schema"]); },
|
|
54
|
+
alter_action_enable: function (print) { return print.spaced(["enableKw", "modeKw", "item"]); },
|
|
55
|
+
alter_action_disable: function (print) { return print.spaced(["disableKw", "item"]); },
|
|
56
|
+
alter_action_force: function (print) { return print.spaced(["forceKw", "item"]); },
|
|
57
|
+
alter_action_no_force: function (print) { return print.spaced(["noForceKw", "item"]); },
|
|
58
|
+
alter_action_cluster_on: function (print) { return print.spaced(["clusterOnKw", "index"]); },
|
|
59
|
+
alter_action_set_without_cluster: function (print) {
|
|
60
|
+
return print.spaced("setWithoutClusterKw");
|
|
61
|
+
},
|
|
62
|
+
alter_action_set_without_oids: function (print) { return print.spaced("setWithoutOidsKw"); },
|
|
63
|
+
alter_action_set_access_method: function (print) {
|
|
64
|
+
return print.spaced(["setAccessMethodKw", "method"]);
|
|
65
|
+
},
|
|
66
|
+
alter_action_set_logged: function (print) { return print.spaced("setLoggedKw"); },
|
|
67
|
+
alter_action_set_unlogged: function (print) { return print.spaced("setUnloggedKw"); },
|
|
68
|
+
alter_action_inherit: function (print) { return print.spaced(["inheritKw", "table"]); },
|
|
69
|
+
alter_action_no_inherit: function (print) { return print.spaced(["noInheritKw", "table"]); },
|
|
70
|
+
alter_action_of_type: function (print) { return print.spaced(["ofKw", "typeName"]); },
|
|
71
|
+
alter_action_not_of_type: function (print) { return print.spaced("notOfKw"); },
|
|
72
|
+
alter_action_owner_to: function (print) { return print.spaced(["ownerToKw", "owner"]); },
|
|
73
|
+
alter_action_replica_identity: function (print) {
|
|
74
|
+
return print.spaced(["replicaIdentityKw", "identity"]);
|
|
75
|
+
},
|
|
76
|
+
replica_identity_using_index: function (print) {
|
|
77
|
+
return print.spaced(["usingIndexKw", "index"]);
|
|
78
|
+
},
|
|
79
|
+
alter_action_set_postgresql_options: function (print) {
|
|
80
|
+
return print.spaced(["setKw", "options"]);
|
|
81
|
+
},
|
|
82
|
+
alter_action_reset_postgresql_options: function (print) {
|
|
83
|
+
return print.spaced(["resetKw", "options"]);
|
|
84
|
+
},
|
|
85
|
+
alter_action_depends_on_extension: function (print) {
|
|
86
|
+
return print.spaced(["dependsOnExtensionKw", "extension"]);
|
|
87
|
+
},
|
|
88
|
+
alter_action_no_depends_on_extension: function (print) {
|
|
89
|
+
return print.spaced(["noDependsOnExtensionKw", "extension"]);
|
|
90
|
+
},
|
|
91
|
+
alter_action_attach_partition: function (print) {
|
|
92
|
+
return print.spaced(["attachPartitionKw", "index"]);
|
|
93
|
+
},
|
|
94
|
+
// ALTER COLUMN
|
|
95
|
+
alter_action_alter_column: function (print) {
|
|
96
|
+
return (0, print_utils_1.group)([
|
|
97
|
+
print.spaced(["alterKw", "ifExistsKw", "column"]),
|
|
98
|
+
print.dynamicLine(),
|
|
99
|
+
print("action"),
|
|
100
|
+
]);
|
|
101
|
+
},
|
|
102
|
+
alter_action_set_default: function (print) { return print.spaced(["setDefaultKw", "expr"]); },
|
|
103
|
+
alter_action_drop_default: function (print) { return print.spaced("dropDefaultKw"); },
|
|
104
|
+
alter_action_set_not_null: function (print) { return print.spaced("setNotNullKw"); },
|
|
105
|
+
alter_action_drop_not_null: function (print) { return print.spaced("dropNotNullKw"); },
|
|
106
|
+
alter_action_set_data_type: function (print) {
|
|
107
|
+
return print.spaced(["setDataTypeKw", "dataType", "clauses"]);
|
|
108
|
+
},
|
|
109
|
+
alter_action_set_statistics: function (print) {
|
|
110
|
+
return print.spaced(["setStatisticsKw", "value"]);
|
|
111
|
+
},
|
|
112
|
+
alter_action_set_compression: function (print) {
|
|
113
|
+
return print.spaced(["setCompressionKw", "method"]);
|
|
114
|
+
},
|
|
115
|
+
alter_action_set_storage: function (print) { return print.spaced(["setStorageKw", "typeKw"]); },
|
|
116
|
+
alter_action_drop_expression: function (print) {
|
|
117
|
+
return print.spaced(["dropExpressionKw", "ifExistsKw"]);
|
|
118
|
+
},
|
|
119
|
+
alter_action_drop_identity: function (print) {
|
|
120
|
+
return print.spaced(["dropIdentityKw", "ifExistsKw"]);
|
|
121
|
+
},
|
|
122
|
+
alter_action_add_identity: function (print) {
|
|
123
|
+
return print.spaced([
|
|
124
|
+
"addGeneratedKw",
|
|
125
|
+
"whenKw",
|
|
126
|
+
"asIdentityKw",
|
|
127
|
+
"sequenceOptions",
|
|
128
|
+
]);
|
|
129
|
+
},
|
|
130
|
+
alter_action_alter_identity: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, print("actions"))); },
|
|
131
|
+
alter_action_set_generated: function (print) {
|
|
132
|
+
return print.spaced(["setGeneratedKw", "whenKw"]);
|
|
133
|
+
},
|
|
134
|
+
alter_action_restart: function (print) {
|
|
135
|
+
return print.spaced(["restartKw", "withKw", "value"]);
|
|
136
|
+
},
|
|
137
|
+
alter_action_set_sequence_option: function (print) {
|
|
138
|
+
return print.spaced(["setKw", "option"]);
|
|
139
|
+
},
|
|
140
|
+
// ENABLE/DISABLE ..
|
|
141
|
+
toggle_trigger: function (print) { return print.spaced(["triggerKw", "name"]); },
|
|
142
|
+
toggle_rule: function (print) { return print.spaced(["ruleKw", "name"]); },
|
|
143
|
+
toggle_row_level_security: function (print) { return print.spaced("rowLevelSecurityKw"); },
|
|
144
|
+
// SET DATA TYPE ...
|
|
145
|
+
set_data_type_collate_clause: function (print) {
|
|
146
|
+
return print.spaced(["collateKw", "collation"]);
|
|
147
|
+
},
|
|
148
|
+
set_data_type_using_clause: function (print) { return print.spaced(["usingKw", "expr"]); },
|
|
149
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AllAlterTableNodes } from "sql-parser-cst";
|
|
2
2
|
import { CstToDocMap } from "../CstToDocMap";
|
|
3
|
-
export declare const alterTableMap: CstToDocMap<
|
|
3
|
+
export declare const alterTableMap: CstToDocMap<AllAlterTableNodes>;
|
|
@@ -10,55 +10,19 @@ exports.alterTableMap = {
|
|
|
10
10
|
print("actions"),
|
|
11
11
|
]);
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
alter_action_rename_column: function (print) {
|
|
15
|
-
return print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]);
|
|
16
|
-
},
|
|
17
|
-
alter_action_add_column: function (print) {
|
|
18
|
-
return print.spaced(["addKw", "ifNotExistsKw", "column"]);
|
|
19
|
-
},
|
|
20
|
-
alter_action_drop_column: function (print) {
|
|
21
|
-
return print.spaced(["dropKw", "ifExistsKw", "column", "behaviorKw"]);
|
|
22
|
-
},
|
|
23
|
-
alter_action_set_options: function (print) { return print.spaced(["setKw", "options"]); },
|
|
24
|
-
alter_action_set_default_collate: function (print) {
|
|
25
|
-
return print.spaced(["setDefaultCollateKw", "collation"]);
|
|
26
|
-
},
|
|
27
|
-
alter_action_add_constraint: function (print) {
|
|
28
|
-
return print.spaced(["addKw", "constraint"]);
|
|
29
|
-
},
|
|
30
|
-
alter_action_drop_constraint: function (print) {
|
|
31
|
-
return print.spaced([
|
|
32
|
-
"dropConstraintKw",
|
|
33
|
-
"ifExistsKw",
|
|
34
|
-
"constraint",
|
|
35
|
-
"behaviorKw",
|
|
36
|
-
]);
|
|
37
|
-
},
|
|
38
|
-
alter_action_alter_constraint: function (print) {
|
|
39
|
-
return print.spaced(["alterConstraintKw", "constraint", "modifiers"]);
|
|
40
|
-
},
|
|
41
|
-
alter_action_rename_constraint: function (print) {
|
|
42
|
-
return print.spaced(["renameConstraintKw", "oldName", "toKw", "newName"]);
|
|
43
|
-
},
|
|
44
|
-
alter_action_validate_constraint: function (print) {
|
|
45
|
-
return print.spaced(["validateConstraintKw", "constraint"]);
|
|
46
|
-
},
|
|
47
|
-
alter_action_set_visible: function (print) { return print.spaced("setVisibleKw"); },
|
|
48
|
-
alter_action_set_invisible: function (print) { return print.spaced("setInvisibleKw"); },
|
|
49
|
-
// ALTER COLUMN
|
|
50
|
-
alter_action_alter_column: function (print) {
|
|
13
|
+
alter_table_all_in_tablespace_stmt: function (print) {
|
|
51
14
|
return (0, print_utils_1.group)([
|
|
52
|
-
print.spaced([
|
|
15
|
+
print.spaced([
|
|
16
|
+
"alterTableKw",
|
|
17
|
+
"allInTablespaceKw",
|
|
18
|
+
"tablespace",
|
|
19
|
+
"ownedBy",
|
|
20
|
+
]),
|
|
53
21
|
print.dynamicLine(),
|
|
54
22
|
print("action"),
|
|
55
23
|
]);
|
|
56
24
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
alter_action_set_not_null: function (print) { return print.spaced("setNotNullKw"); },
|
|
60
|
-
alter_action_drop_not_null: function (print) { return print.spaced("dropNotNullKw"); },
|
|
61
|
-
alter_action_set_data_type: function (print) {
|
|
62
|
-
return print.spaced(["setDataTypeKw", "dataType"]);
|
|
25
|
+
owned_by_clause: function (print) {
|
|
26
|
+
return (0, print_utils_1.group)([print.spaced("ownedByKw"), (0, print_utils_1.indent)([print_utils_1.line, print("owners")])]);
|
|
63
27
|
},
|
|
64
28
|
};
|
|
@@ -35,6 +35,7 @@ exports.constraintMap = {
|
|
|
35
35
|
constraint_unique: function (print) {
|
|
36
36
|
return (0, print_utils_1.group)(print.spaced(["uniqueKw", "columns", "nullsKw", "clauses"]));
|
|
37
37
|
},
|
|
38
|
+
existing_index: function (print) { return print.spaced(["usingIndexKw", "index"]); },
|
|
38
39
|
constraint_check: function (print) {
|
|
39
40
|
return (0, print_utils_1.group)(print.spaced(["checkKw", "expr", "clauses"]));
|
|
40
41
|
},
|
|
@@ -56,15 +57,18 @@ exports.constraintMap = {
|
|
|
56
57
|
return baseDoc;
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
|
-
index_specification: function (print) {
|
|
60
|
-
return print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]);
|
|
61
|
-
},
|
|
62
60
|
referential_action: function (print) {
|
|
63
61
|
return print.spaced(["onKw", "eventKw", "actionKw", "columns"]);
|
|
64
62
|
},
|
|
65
63
|
referential_match: function (print) { return print.spaced(["matchKw", "typeKw"]); },
|
|
66
64
|
constraint_generated: function (print) {
|
|
67
|
-
return print.spaced([
|
|
65
|
+
return print.spaced([
|
|
66
|
+
"generatedKw",
|
|
67
|
+
"asKw",
|
|
68
|
+
"expr",
|
|
69
|
+
"storageKw",
|
|
70
|
+
"sequenceOptions",
|
|
71
|
+
]);
|
|
68
72
|
},
|
|
69
73
|
identity_column: function (print) { return print("identityKw"); },
|
|
70
74
|
constraint_auto_increment: function (print) { return print("autoIncrementKw"); },
|
|
@@ -94,7 +98,6 @@ exports.constraintMap = {
|
|
|
94
98
|
]);
|
|
95
99
|
},
|
|
96
100
|
exclusion_param: function (print) { return print.spaced(["index", "withKw", "operator"]); },
|
|
97
|
-
index_include_clause: function (print) { return print.spaced(["includeKw", "columns"]); },
|
|
98
101
|
index_tablespace_clause: function (print) {
|
|
99
102
|
return print.spaced(["usingIndexTablespaceKw", "name"]);
|
|
100
103
|
},
|
|
@@ -35,7 +35,7 @@ exports.createTableMap = {
|
|
|
35
35
|
node.options ? [print_utils_1.line, (0, print_utils_1.group)(print("options"))] : [],
|
|
36
36
|
];
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
relation_kind: function (print) { return print.spaced("kindKw"); },
|
|
39
39
|
column_definition: function (print) {
|
|
40
40
|
return print.spaced(["name", "dataType", "withOptionsKw", "constraints"]);
|
|
41
41
|
},
|
|
@@ -86,17 +86,13 @@ exports.createTableMap = {
|
|
|
86
86
|
create_table_default_partition_clause: function (print) { return print.spaced("defaultKw"); },
|
|
87
87
|
create_table_of_type_clause: function (print) { return print.spaced(["ofKw", "typeName"]); },
|
|
88
88
|
using_access_method_clause: function (print) { return print.spaced(["usingKw", "method"]); },
|
|
89
|
-
|
|
90
|
-
return print.spaced(["tablespaceKw", "name"]);
|
|
91
|
-
},
|
|
92
|
-
with_storage_parameters_clause: function (print) {
|
|
93
|
-
return print.spaced(["withKw", "options"]);
|
|
94
|
-
},
|
|
89
|
+
tablespace_clause: function (print) { return print.spaced(["tablespaceKw", "name"]); },
|
|
95
90
|
create_table_without_oids_clause: function (print) { return print.spaced("withoutOidsKw"); },
|
|
96
91
|
create_table_on_commit_clause: function (print) {
|
|
97
92
|
return print.spaced(["onCommitKw", "actionKw"]);
|
|
98
93
|
},
|
|
99
|
-
|
|
94
|
+
with_data_clause: function (print) { return print.spaced("withDataKw"); },
|
|
95
|
+
create_table_server_clause: function (print) { return print.spaced(["serverKw", "name"]); },
|
|
100
96
|
};
|
|
101
97
|
var printClauses = function (print, node) {
|
|
102
98
|
if (node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0])) {
|
|
@@ -4,5 +4,8 @@ exports.postgresqlMap = void 0;
|
|
|
4
4
|
exports.postgresqlMap = {
|
|
5
5
|
postgresql_operator_expr: function (print) { return print(["operatorKw", "expr"]); },
|
|
6
6
|
postgresql_operator: function (print) { return print("operator"); },
|
|
7
|
-
postgresql_operator_class: function (print) { return print("name"); },
|
|
7
|
+
postgresql_operator_class: function (print) { return print.spaced(["name", "options"]); },
|
|
8
|
+
postgresql_with_options: function (print) { return print.spaced(["withKw", "options"]); },
|
|
9
|
+
postgresql_options: function (print) { return print.spaced(["optionsKw", "options"]); },
|
|
10
|
+
postgresql_option_element: function (print) { return print.spaced(["name", "value"]); },
|
|
8
11
|
};
|
|
@@ -12,7 +12,6 @@ exports.sqliteMap = {
|
|
|
12
12
|
vacuum_stmt: function (print) {
|
|
13
13
|
return print.spaced(["vacuumKw", "schema", "intoKw", "file"]);
|
|
14
14
|
},
|
|
15
|
-
reindex_stmt: function (print) { return print.spaced(["reindexKw", "table"]); },
|
|
16
15
|
pragma_stmt: function (print) { return print.spaced(["pragmaKw", "pragma"]); },
|
|
17
16
|
pragma_assignment: function (print) { return (0, print_utils_1.join)(" = ", print(["name", "value"])); },
|
|
18
17
|
pragma_func_call: function (print) { return print(["name", "args"]); },
|
package/dist/syntax/index.js
CHANGED
|
@@ -16,26 +16,72 @@ exports.indexMap = {
|
|
|
16
16
|
return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
|
|
17
17
|
print.spaced([
|
|
18
18
|
"createKw",
|
|
19
|
+
"orReplaceKw",
|
|
19
20
|
"indexTypeKw",
|
|
20
21
|
"indexKw",
|
|
22
|
+
"concurrentlyKw",
|
|
21
23
|
"ifNotExistsKw",
|
|
22
24
|
"name",
|
|
23
25
|
"onKw",
|
|
24
26
|
"table",
|
|
27
|
+
"using",
|
|
25
28
|
"columns",
|
|
26
29
|
])
|
|
27
30
|
], print("clauses"), true)));
|
|
28
31
|
},
|
|
32
|
+
index_specification: function (print) {
|
|
33
|
+
return print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]);
|
|
34
|
+
},
|
|
35
|
+
index_include_clause: function (print) { return print.spaced(["includeKw", "columns"]); },
|
|
36
|
+
index_nulls_distinct_clause: function (print) { return print.spaced(["nullsDistinctKw"]); },
|
|
37
|
+
index_nulls_not_distinct_clause: function (print) {
|
|
38
|
+
return print.spaced(["nullsNotDistinctKw"]);
|
|
39
|
+
},
|
|
29
40
|
drop_index_stmt: function (print) {
|
|
30
|
-
return print.spaced([
|
|
41
|
+
return (0, print_utils_1.group)(print.spaced([
|
|
31
42
|
"dropKw",
|
|
32
43
|
"indexTypeKw",
|
|
33
44
|
"indexKw",
|
|
45
|
+
"concurrentlyKw",
|
|
34
46
|
"ifExistsKw",
|
|
35
47
|
"indexes",
|
|
36
48
|
"onKw",
|
|
37
49
|
"table",
|
|
38
|
-
|
|
50
|
+
"behaviorKw",
|
|
51
|
+
]));
|
|
39
52
|
},
|
|
40
53
|
verbose_all_columns: function (print) { return print.spaced("allColumnsKw"); },
|
|
54
|
+
alter_index_stmt: function (print) {
|
|
55
|
+
return (0, print_utils_1.group)([
|
|
56
|
+
print.spaced(["alterKw", "indexKw", "ifExistsKw", "index"]),
|
|
57
|
+
print.dynamicLine(),
|
|
58
|
+
print("action"),
|
|
59
|
+
]);
|
|
60
|
+
},
|
|
61
|
+
alter_index_all_in_tablespace_stmt: function (print) {
|
|
62
|
+
return (0, print_utils_1.group)([
|
|
63
|
+
print.spaced([
|
|
64
|
+
"alterIndexKw",
|
|
65
|
+
"allInTablespaceKw",
|
|
66
|
+
"tablespace",
|
|
67
|
+
"ownedBy",
|
|
68
|
+
]),
|
|
69
|
+
print.dynamicLine(),
|
|
70
|
+
print("action"),
|
|
71
|
+
]);
|
|
72
|
+
},
|
|
73
|
+
reindex_stmt: function (print) {
|
|
74
|
+
return print.spaced([
|
|
75
|
+
"reindexKw",
|
|
76
|
+
"options",
|
|
77
|
+
"targetKw",
|
|
78
|
+
"concurrentlyKw",
|
|
79
|
+
"name",
|
|
80
|
+
]);
|
|
81
|
+
},
|
|
82
|
+
reindex_option_concurrently: function (print) {
|
|
83
|
+
return print.spaced(["concurrentlyKw", "value"]);
|
|
84
|
+
},
|
|
85
|
+
reindex_option_tablespace: function (print) { return print.spaced(["tablespaceKw", "name"]); },
|
|
86
|
+
reindex_option_verbose: function (print) { return print.spaced(["verboseKw", "value"]); },
|
|
41
87
|
};
|
package/dist/syntax/schema.js
CHANGED
|
@@ -12,17 +12,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.schemaMap = void 0;
|
|
13
13
|
var print_utils_1 = require("../print_utils");
|
|
14
14
|
exports.schemaMap = {
|
|
15
|
-
create_schema_stmt: function (print) {
|
|
16
|
-
return (0, print_utils_1.
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
create_schema_stmt: function (print, node) {
|
|
16
|
+
return (0, print_utils_1.group)([
|
|
17
|
+
(0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
|
|
18
|
+
print.spaced(["createSchemaKw", "ifNotExistsKw", "name"])
|
|
19
|
+
], print("clauses"), true))),
|
|
20
|
+
node.statements.length > 0
|
|
21
|
+
? (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("statements"))])
|
|
22
|
+
: [],
|
|
23
|
+
]);
|
|
24
|
+
},
|
|
25
|
+
create_schema_authorization_clause: function (print) {
|
|
26
|
+
return print.spaced(["authorizationKw", "role"]);
|
|
19
27
|
},
|
|
20
28
|
drop_schema_stmt: function (print) {
|
|
21
|
-
return print.spaced(["dropSchemaKw", "ifExistsKw", "
|
|
29
|
+
return print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"]);
|
|
22
30
|
},
|
|
23
31
|
alter_schema_stmt: function (print) {
|
|
24
|
-
return (0, print_utils_1.
|
|
32
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
|
|
25
33
|
print.spaced(["alterSchemaKw", "ifExistsKw", "name"])
|
|
26
|
-
], print("actions"), true));
|
|
34
|
+
], print("actions"), true)));
|
|
27
35
|
},
|
|
28
36
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sequenceMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.sequenceMap = {
|
|
6
|
+
create_sequence_stmt: function (print) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
8
|
+
print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
|
|
9
|
+
(0, print_utils_1.indent)([print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("options"))]),
|
|
10
|
+
]);
|
|
11
|
+
},
|
|
12
|
+
alter_sequence_stmt: function (print) {
|
|
13
|
+
return (0, print_utils_1.group)([
|
|
14
|
+
print.spaced(["alterKw", "sequenceKw", "ifExistsKw", "sequence"]),
|
|
15
|
+
(0, print_utils_1.indent)([print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("actions"))]),
|
|
16
|
+
]);
|
|
17
|
+
},
|
|
18
|
+
drop_sequence_stmt: function (print) {
|
|
19
|
+
return (0, print_utils_1.group)(print.spaced([
|
|
20
|
+
"dropKw",
|
|
21
|
+
"sequenceKw",
|
|
22
|
+
"ifExistsKw",
|
|
23
|
+
"sequences",
|
|
24
|
+
"behaviorKw",
|
|
25
|
+
]));
|
|
26
|
+
},
|
|
27
|
+
sequence_option_as_type: function (print) { return print.spaced(["asKw", "dataType"]); },
|
|
28
|
+
sequence_option_increment: function (print) {
|
|
29
|
+
return print.spaced(["incrementKw", "byKw", "value"]);
|
|
30
|
+
},
|
|
31
|
+
sequence_option_minvalue: function (print) { return print.spaced(["minvalueKw", "value"]); },
|
|
32
|
+
sequence_option_maxvalue: function (print) { return print.spaced(["maxvalueKw", "value"]); },
|
|
33
|
+
sequence_option_no_minvalue: function (print) { return print.spaced("noMinvalueKw"); },
|
|
34
|
+
sequence_option_no_maxvalue: function (print) { return print.spaced("noMaxvalueKw"); },
|
|
35
|
+
sequence_option_start: function (print) {
|
|
36
|
+
return print.spaced(["startKw", "withKw", "value"]);
|
|
37
|
+
},
|
|
38
|
+
sequence_option_restart: function (print) {
|
|
39
|
+
return print.spaced(["restartKw", "withKw", "value"]);
|
|
40
|
+
},
|
|
41
|
+
sequence_option_cache: function (print) { return print.spaced(["cacheKw", "value"]); },
|
|
42
|
+
sequence_option_cycle: function (print) { return print.spaced("cycleKw"); },
|
|
43
|
+
sequence_option_no_cycle: function (print) { return print.spaced("noCycleKw"); },
|
|
44
|
+
sequence_option_owned_by: function (print) { return print.spaced(["ownedByKw", "owner"]); },
|
|
45
|
+
sequence_option_list: function (print) { return (0, print_utils_1.join)(print_utils_1.line, print("options")); },
|
|
46
|
+
};
|
|
@@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.transformMap = void 0;
|
|
15
15
|
var alias_1 = require("./alias");
|
|
16
|
+
var alter_action_1 = require("./alter_action");
|
|
16
17
|
var alter_table_1 = require("./alter_table");
|
|
17
18
|
var analyze_1 = require("./analyze");
|
|
18
19
|
var base_1 = require("./base");
|
|
@@ -38,6 +39,7 @@ var proc_clause_1 = require("./proc_clause");
|
|
|
38
39
|
var program_1 = require("./program");
|
|
39
40
|
var schema_1 = require("./schema");
|
|
40
41
|
var select_1 = require("./select");
|
|
42
|
+
var sequence_1 = require("./sequence");
|
|
41
43
|
var transaction_1 = require("./transaction");
|
|
42
44
|
var trigger_1 = require("./trigger");
|
|
43
45
|
var truncate_1 = require("./truncate");
|
|
@@ -47,4 +49,4 @@ var bigquery_1 = require("./dialects/bigquery");
|
|
|
47
49
|
var mysql_1 = require("./dialects/mysql");
|
|
48
50
|
var sqlite_1 = require("./dialects/sqlite");
|
|
49
51
|
var postgresql_1 = require("./dialects/postgresql");
|
|
50
|
-
exports.transformMap = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), other_clauses_1.otherClausesMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), rename_table_1.renameTableMap), schema_1.schemaMap), select_1.selectMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
|
52
|
+
exports.transformMap = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), other_clauses_1.otherClausesMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), rename_table_1.renameTableMap), schema_1.schemaMap), select_1.selectMap), sequence_1.sequenceMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
package/dist/syntax/truncate.js
CHANGED
|
@@ -8,11 +8,7 @@ exports.truncateMap = {
|
|
|
8
8
|
print.spaced(["truncateKw", "tableKw"]),
|
|
9
9
|
(0, print_utils_1.indent)([
|
|
10
10
|
print_utils_1.line,
|
|
11
|
-
print.separated(print_utils_1.line, [
|
|
12
|
-
"tables",
|
|
13
|
-
"restartOrContinueKw",
|
|
14
|
-
"cascadeOrRestrictKw",
|
|
15
|
-
]),
|
|
11
|
+
print.separated(print_utils_1.line, ["tables", "restartOrContinueKw", "behaviorKw"]),
|
|
16
12
|
]),
|
|
17
13
|
]);
|
|
18
14
|
},
|
package/dist/syntax/view.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AllViewNodes } from "sql-parser-cst";
|
|
2
2
|
import { CstToDocMap } from "../CstToDocMap";
|
|
3
|
-
export declare const viewMap: CstToDocMap<
|
|
3
|
+
export declare const viewMap: CstToDocMap<AllViewNodes>;
|
package/dist/syntax/view.js
CHANGED
|
@@ -10,8 +10,7 @@ exports.viewMap = {
|
|
|
10
10
|
print.spaced([
|
|
11
11
|
"createKw",
|
|
12
12
|
"orReplaceKw",
|
|
13
|
-
"
|
|
14
|
-
"materializedKw",
|
|
13
|
+
"kinds",
|
|
15
14
|
"viewKw",
|
|
16
15
|
"ifNotExistsKw",
|
|
17
16
|
"name",
|
|
@@ -21,26 +20,38 @@ exports.viewMap = {
|
|
|
21
20
|
hasManyClauses ? [print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))] : [],
|
|
22
21
|
];
|
|
23
22
|
},
|
|
23
|
+
with_check_option_clause: function (print) {
|
|
24
|
+
return print.spaced(["withKw", "levelKw", "checkOptionKw"]);
|
|
25
|
+
},
|
|
26
|
+
as_replica_of_clause: function (print) { return print.spaced(["asReplicaOfKw", "view"]); },
|
|
24
27
|
drop_view_stmt: function (print) {
|
|
25
|
-
return print.spaced([
|
|
28
|
+
return (0, print_utils_1.group)(print.spaced([
|
|
26
29
|
"dropKw",
|
|
27
|
-
"
|
|
30
|
+
"kind",
|
|
28
31
|
"viewKw",
|
|
29
32
|
"ifExistsKw",
|
|
30
33
|
"views",
|
|
31
34
|
"behaviorKw",
|
|
32
|
-
]);
|
|
35
|
+
]));
|
|
33
36
|
},
|
|
34
37
|
alter_view_stmt: function (print) { return [
|
|
35
38
|
print.spaced([
|
|
36
39
|
"alterKw",
|
|
37
|
-
"
|
|
40
|
+
"kind",
|
|
38
41
|
"viewKw",
|
|
39
42
|
"ifExistsKw",
|
|
40
43
|
"name",
|
|
41
44
|
"columns",
|
|
42
45
|
]),
|
|
43
46
|
print_utils_1.hardline,
|
|
44
|
-
|
|
47
|
+
print("actions"),
|
|
45
48
|
]; },
|
|
49
|
+
refresh_materialized_view_stmt: function (print, node) {
|
|
50
|
+
return (0, print_utils_1.group)([
|
|
51
|
+
print.spaced(["refreshMaterializedViewKw", "concurrentlyKw", "name"]),
|
|
52
|
+
node.clauses.length > 0
|
|
53
|
+
? [print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("clauses"))]
|
|
54
|
+
: [],
|
|
55
|
+
]);
|
|
56
|
+
},
|
|
46
57
|
};
|
|
@@ -6,7 +6,7 @@ var transformUtils_1 = require("./transformUtils");
|
|
|
6
6
|
var canonicKeywords = function (cst) {
|
|
7
7
|
(0, sql_parser_cst_1.cstVisitor)({
|
|
8
8
|
// Replaces TEMP with TEMPORARY
|
|
9
|
-
|
|
9
|
+
relation_kind: function (node) {
|
|
10
10
|
if (Array.isArray(node.kindKw)) {
|
|
11
11
|
// TODO...
|
|
12
12
|
}
|
|
@@ -25,7 +25,7 @@ var canonicKeywords = function (cst) {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
// Replaces RENAME & RENAME AS with RENAME TO
|
|
28
|
-
|
|
28
|
+
alter_action_rename: function (node) {
|
|
29
29
|
if (Array.isArray(node.renameKw)) {
|
|
30
30
|
if (node.renameKw[1].name === "AS") {
|
|
31
31
|
node.renameKw[1].name = "TO";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"author": "Rene Saarsoo <nene@triin.net>",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -33,10 +33,11 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"prettier": "^3.0.3",
|
|
36
|
-
"sql-parser-cst": "^0.
|
|
36
|
+
"sql-parser-cst": "^0.27.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/jest": "^29.2.5",
|
|
40
|
+
"chalk": "^4.3.0",
|
|
40
41
|
"dedent-js": "^1.0.1",
|
|
41
42
|
"jest": "^29.7.0",
|
|
42
43
|
"ts-jest": "^29.1.1",
|