prettier-plugin-sql-cst 0.18.0 → 0.19.1
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/CstToDocMap.d.ts +2 -2
- package/dist/CstToDocMap.js +1 -2
- package/dist/PrintFn.js +1 -2
- package/dist/embed.js +5 -13
- package/dist/embedJs.js +28 -84
- package/dist/embedJson.js +29 -85
- package/dist/embedSql.js +26 -76
- package/dist/index.js +28 -34
- package/dist/node_utils.d.ts +1 -0
- package/dist/node_utils.js +44 -54
- package/dist/options.js +1 -4
- package/dist/printComment.js +2 -6
- package/dist/printSql.js +29 -39
- package/dist/print_utils.js +19 -38
- package/dist/syntax/alias.js +2 -5
- package/dist/syntax/alter_action.js +115 -208
- package/dist/syntax/alter_table.js +18 -27
- package/dist/syntax/analyze.js +3 -8
- package/dist/syntax/base.js +6 -9
- package/dist/syntax/cast.js +3 -6
- package/dist/syntax/comment.js +53 -122
- package/dist/syntax/constraint.d.ts +1 -1
- package/dist/syntax/constraint.js +54 -90
- package/dist/syntax/create_table.js +49 -87
- package/dist/syntax/data_type.js +25 -44
- package/dist/syntax/dcl.js +78 -136
- package/dist/syntax/delete.js +4 -9
- package/dist/syntax/dialects/bigquery.js +70 -116
- package/dist/syntax/dialects/mysql.js +2 -5
- package/dist/syntax/dialects/postgresql.js +8 -13
- package/dist/syntax/dialects/sqlite.js +8 -17
- package/dist/syntax/do.js +3 -6
- package/dist/syntax/domain.js +10 -19
- package/dist/syntax/drop_table.js +10 -15
- package/dist/syntax/explain.js +6 -11
- package/dist/syntax/expr.js +124 -173
- package/dist/syntax/extension.js +12 -21
- package/dist/syntax/frame.js +11 -16
- package/dist/syntax/function.js +53 -63
- package/dist/syntax/index.js +54 -81
- package/dist/syntax/insert.js +32 -49
- package/dist/syntax/merge.js +25 -30
- package/dist/syntax/other_clauses.js +5 -14
- package/dist/syntax/parameter.js +13 -26
- package/dist/syntax/policy.js +26 -41
- package/dist/syntax/prepared_statements.js +23 -43
- package/dist/syntax/proc_clause.js +10 -15
- package/dist/syntax/procedural_language.js +80 -111
- package/dist/syntax/procedure.js +36 -40
- package/dist/syntax/program.js +15 -22
- package/dist/syntax/publication.js +26 -47
- package/dist/syntax/rename_table.js +7 -12
- package/dist/syntax/role.js +30 -55
- package/dist/syntax/schema.js +17 -35
- package/dist/syntax/select.js +157 -226
- package/dist/syntax/sequence.js +35 -52
- package/dist/syntax/subscription.js +9 -24
- package/dist/syntax/transaction.js +18 -33
- package/dist/syntax/transformMap.js +99 -63
- package/dist/syntax/trigger.js +48 -72
- package/dist/syntax/truncate.js +9 -14
- package/dist/syntax/type.js +11 -22
- package/dist/syntax/unsupported_grammar.js +3 -6
- package/dist/syntax/update.js +7 -14
- package/dist/syntax/view.js +32 -43
- package/dist/transform/addFinalSemicolon.js +5 -9
- package/dist/transform/aliasAs.js +4 -8
- package/dist/transform/canonicKeywords.js +16 -20
- package/dist/transform/canonicOperators.js +8 -12
- package/dist/transform/comments.js +10 -31
- package/dist/transform/stripTrailingCommas.js +7 -11
- package/dist/transform/transformCst.js +13 -17
- package/dist/transform/transformUtils.js +2 -6
- package/dist/utils.js +9 -30
- package/dist/visitAllNodes.js +8 -13
- package/package.json +9 -8
package/dist/syntax/cast.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var print_utils_1 = require("../print_utils");
|
|
5
|
-
exports.castMap = {
|
|
6
|
-
cast_definition: function (print) { return (0, print_utils_1.group)(print.spaced(["from", "asKw", "to"])); },
|
|
1
|
+
import { group } from "../print_utils";
|
|
2
|
+
export const castMap = {
|
|
3
|
+
cast_definition: (print) => group(print.spaced(["from", "asKw", "to"])),
|
|
7
4
|
};
|
package/dist/syntax/comment.js
CHANGED
|
@@ -1,123 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
comment_target_foreign_table: function (print) {
|
|
55
|
-
return (0, print_utils_1.group)(print.spaced(["foreignTableKw", "name"]));
|
|
56
|
-
},
|
|
57
|
-
comment_target_index: function (print) { return (0, print_utils_1.group)(print.spaced(["indexKw", "name"])); },
|
|
58
|
-
comment_target_language: function (print) {
|
|
59
|
-
return (0, print_utils_1.group)(print.spaced(["languageKw", "name"]));
|
|
60
|
-
},
|
|
61
|
-
comment_target_large_object: function (print) {
|
|
62
|
-
return (0, print_utils_1.group)(print.spaced(["largeObjectKw", "oid"]));
|
|
63
|
-
},
|
|
64
|
-
comment_target_materialized_view: function (print) {
|
|
65
|
-
return (0, print_utils_1.group)(print.spaced(["materializedViewKw", "name"]));
|
|
66
|
-
},
|
|
67
|
-
comment_target_operator_class: function (print) {
|
|
68
|
-
return (0, print_utils_1.group)(print.spaced(["operatorClassKw", "name", "usingKw", "methodName"]));
|
|
69
|
-
},
|
|
70
|
-
comment_target_operator_family: function (print) {
|
|
71
|
-
return (0, print_utils_1.group)(print.spaced(["operatorFamilyKw", "name", "usingKw", "methodName"]));
|
|
72
|
-
},
|
|
73
|
-
comment_target_policy: function (print) {
|
|
74
|
-
return (0, print_utils_1.group)(print.spaced(["policyKw", "name", "onKw", "tableName"]));
|
|
75
|
-
},
|
|
76
|
-
comment_target_publication: function (print) {
|
|
77
|
-
return (0, print_utils_1.group)(print.spaced(["publicationKw", "name"]));
|
|
78
|
-
},
|
|
79
|
-
comment_target_role: function (print) { return (0, print_utils_1.group)(print.spaced(["roleKw", "name"])); },
|
|
80
|
-
comment_target_rule: function (print) {
|
|
81
|
-
return (0, print_utils_1.group)(print.spaced(["ruleKw", "name", "onKw", "tableName"]));
|
|
82
|
-
},
|
|
83
|
-
comment_target_schema: function (print) { return (0, print_utils_1.group)(print.spaced(["schemaKw", "name"])); },
|
|
84
|
-
comment_target_sequence: function (print) {
|
|
85
|
-
return (0, print_utils_1.group)(print.spaced(["sequenceKw", "name"]));
|
|
86
|
-
},
|
|
87
|
-
comment_target_server: function (print) { return (0, print_utils_1.group)(print.spaced(["serverKw", "name"])); },
|
|
88
|
-
comment_target_statistics: function (print) {
|
|
89
|
-
return (0, print_utils_1.group)(print.spaced(["statisticsKw", "name"]));
|
|
90
|
-
},
|
|
91
|
-
comment_target_subscription: function (print) {
|
|
92
|
-
return (0, print_utils_1.group)(print.spaced(["subscriptionKw", "name"]));
|
|
93
|
-
},
|
|
94
|
-
comment_target_table: function (print) { return (0, print_utils_1.group)(print.spaced(["tableKw", "name"])); },
|
|
95
|
-
comment_target_tablespace: function (print) {
|
|
96
|
-
return (0, print_utils_1.group)(print.spaced(["tablespaceKw", "name"]));
|
|
97
|
-
},
|
|
98
|
-
comment_target_text_search_configuration: function (print) {
|
|
99
|
-
return (0, print_utils_1.group)(print.spaced(["textSearchConfigurationKw", "name"]));
|
|
100
|
-
},
|
|
101
|
-
comment_target_text_search_dictionary: function (print) {
|
|
102
|
-
return (0, print_utils_1.group)(print.spaced(["textSearchDictionaryKw", "name"]));
|
|
103
|
-
},
|
|
104
|
-
comment_target_text_search_parser: function (print) {
|
|
105
|
-
return (0, print_utils_1.group)(print.spaced(["textSearchParserKw", "name"]));
|
|
106
|
-
},
|
|
107
|
-
comment_target_text_search_template: function (print) {
|
|
108
|
-
return (0, print_utils_1.group)(print.spaced(["textSearchTemplateKw", "name"]));
|
|
109
|
-
},
|
|
110
|
-
comment_target_transform: function (print) {
|
|
111
|
-
return (0, print_utils_1.group)(print.spaced([
|
|
112
|
-
"transformForKw",
|
|
113
|
-
"typeName",
|
|
114
|
-
"languageKw",
|
|
115
|
-
"languageName",
|
|
116
|
-
]));
|
|
117
|
-
},
|
|
118
|
-
comment_target_trigger: function (print) {
|
|
119
|
-
return (0, print_utils_1.group)(print.spaced(["triggerKw", "name", "onKw", "tableName"]));
|
|
120
|
-
},
|
|
121
|
-
comment_target_type: function (print) { return (0, print_utils_1.group)(print.spaced(["typeKw", "name"])); },
|
|
122
|
-
comment_target_view: function (print) { return (0, print_utils_1.group)(print.spaced(["viewKw", "name"])); },
|
|
1
|
+
import { group, indent, line } from "../print_utils";
|
|
2
|
+
export const commentMap = {
|
|
3
|
+
comment_stmt: (print) => group([
|
|
4
|
+
print.spaced(["commentKw", "onKw", "target", "isKw"]),
|
|
5
|
+
indent([line, print("message")]),
|
|
6
|
+
]),
|
|
7
|
+
comment_target_aggregate: (print) => group([print.spaced(["aggregateKw", "name"]), print(["params"])]),
|
|
8
|
+
comment_target_function: (print) => group([print.spaced(["functionKw", "name"]), print(["params"])]),
|
|
9
|
+
comment_target_procedure: (print) => group([print.spaced(["procedureKw", "name"]), print(["params"])]),
|
|
10
|
+
comment_target_routine: (print) => group([print.spaced(["routineKw", "name"]), print(["params"])]),
|
|
11
|
+
comment_target_access_method: (print) => group(print.spaced(["accessMethodKw", "name"])),
|
|
12
|
+
comment_target_cast: (print) => group(print.spaced(["castKw", "args"])),
|
|
13
|
+
comment_target_collation: (print) => group(print.spaced(["collationKw", "name"])),
|
|
14
|
+
comment_target_column: (print) => group(print.spaced(["columnKw", "name"])),
|
|
15
|
+
comment_target_table_constraint: (print) => group(print.spaced(["constraintKw", "name", "onKw", "tableName"])),
|
|
16
|
+
comment_target_domain_constraint: (print) => group(print.spaced(["constraintKw", "name", "onKw", "domainKw", "domainName"])),
|
|
17
|
+
comment_target_conversion: (print) => group(print.spaced(["conversionKw", "name"])),
|
|
18
|
+
comment_target_database: (print) => group(print.spaced(["databaseKw", "name"])),
|
|
19
|
+
comment_target_domain: (print) => group(print.spaced(["domainKw", "name"])),
|
|
20
|
+
comment_target_extension: (print) => group(print.spaced(["extensionKw", "name"])),
|
|
21
|
+
comment_target_event_trigger: (print) => group(print.spaced(["eventTriggerKw", "name"])),
|
|
22
|
+
comment_target_foreign_data_wrapper: (print) => group(print.spaced(["foreignDataWrapperKw", "name"])),
|
|
23
|
+
comment_target_foreign_table: (print) => group(print.spaced(["foreignTableKw", "name"])),
|
|
24
|
+
comment_target_index: (print) => group(print.spaced(["indexKw", "name"])),
|
|
25
|
+
comment_target_language: (print) => group(print.spaced(["languageKw", "name"])),
|
|
26
|
+
comment_target_large_object: (print) => group(print.spaced(["largeObjectKw", "oid"])),
|
|
27
|
+
comment_target_materialized_view: (print) => group(print.spaced(["materializedViewKw", "name"])),
|
|
28
|
+
comment_target_operator_class: (print) => group(print.spaced(["operatorClassKw", "name", "usingKw", "methodName"])),
|
|
29
|
+
comment_target_operator_family: (print) => group(print.spaced(["operatorFamilyKw", "name", "usingKw", "methodName"])),
|
|
30
|
+
comment_target_policy: (print) => group(print.spaced(["policyKw", "name", "onKw", "tableName"])),
|
|
31
|
+
comment_target_publication: (print) => group(print.spaced(["publicationKw", "name"])),
|
|
32
|
+
comment_target_role: (print) => group(print.spaced(["roleKw", "name"])),
|
|
33
|
+
comment_target_rule: (print) => group(print.spaced(["ruleKw", "name", "onKw", "tableName"])),
|
|
34
|
+
comment_target_schema: (print) => group(print.spaced(["schemaKw", "name"])),
|
|
35
|
+
comment_target_sequence: (print) => group(print.spaced(["sequenceKw", "name"])),
|
|
36
|
+
comment_target_server: (print) => group(print.spaced(["serverKw", "name"])),
|
|
37
|
+
comment_target_statistics: (print) => group(print.spaced(["statisticsKw", "name"])),
|
|
38
|
+
comment_target_subscription: (print) => group(print.spaced(["subscriptionKw", "name"])),
|
|
39
|
+
comment_target_table: (print) => group(print.spaced(["tableKw", "name"])),
|
|
40
|
+
comment_target_tablespace: (print) => group(print.spaced(["tablespaceKw", "name"])),
|
|
41
|
+
comment_target_text_search_configuration: (print) => group(print.spaced(["textSearchConfigurationKw", "name"])),
|
|
42
|
+
comment_target_text_search_dictionary: (print) => group(print.spaced(["textSearchDictionaryKw", "name"])),
|
|
43
|
+
comment_target_text_search_parser: (print) => group(print.spaced(["textSearchParserKw", "name"])),
|
|
44
|
+
comment_target_text_search_template: (print) => group(print.spaced(["textSearchTemplateKw", "name"])),
|
|
45
|
+
comment_target_transform: (print) => group(print.spaced([
|
|
46
|
+
"transformForKw",
|
|
47
|
+
"typeName",
|
|
48
|
+
"languageKw",
|
|
49
|
+
"languageName",
|
|
50
|
+
])),
|
|
51
|
+
comment_target_trigger: (print) => group(print.spaced(["triggerKw", "name", "onKw", "tableName"])),
|
|
52
|
+
comment_target_type: (print) => group(print.spaced(["typeKw", "name"])),
|
|
53
|
+
comment_target_view: (print) => group(print.spaced(["viewKw", "name"])),
|
|
123
54
|
};
|
|
@@ -3,4 +3,4 @@ import { AllConstraintNodes, AlterActionAddConstraint, Constraint } from "sql-pa
|
|
|
3
3
|
import { CstToDocMap } from "../CstToDocMap";
|
|
4
4
|
import { PrintFn } from "../PrintFn";
|
|
5
5
|
export declare const constraintMap: CstToDocMap<AllConstraintNodes>;
|
|
6
|
-
export declare const printUnnamedConstraint: <T>(print: PrintFn<Constraint<T
|
|
6
|
+
export declare const printUnnamedConstraint: <T>(print: PrintFn<Constraint<T>> | PrintFn<AlterActionAddConstraint>, node: Constraint<T> | AlterActionAddConstraint) => Doc;
|
|
@@ -1,116 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.printUnnamedConstraint = exports.constraintMap = void 0;
|
|
13
|
-
var print_utils_1 = require("../print_utils");
|
|
14
|
-
exports.constraintMap = {
|
|
1
|
+
import { group, indent, line, hardline, join } from "../print_utils";
|
|
2
|
+
export const constraintMap = {
|
|
15
3
|
/** cst-ignore: constraint, modifiers */
|
|
16
|
-
constraint:
|
|
4
|
+
constraint: (print, node) => {
|
|
17
5
|
if (node.name) {
|
|
18
|
-
return
|
|
6
|
+
return group([
|
|
19
7
|
print("name"),
|
|
20
|
-
|
|
8
|
+
indent([line, printUnnamedConstraint(print, node)]),
|
|
21
9
|
]);
|
|
22
10
|
}
|
|
23
11
|
else {
|
|
24
|
-
return
|
|
12
|
+
return printUnnamedConstraint(print, node);
|
|
25
13
|
}
|
|
26
14
|
},
|
|
27
|
-
constraint_name:
|
|
28
|
-
constraint_modifier:
|
|
29
|
-
constraint_null:
|
|
30
|
-
constraint_not_null:
|
|
31
|
-
constraint_default:
|
|
32
|
-
constraint_primary_key:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return (0, print_utils_1.group)(print.spaced(["checkKw", "expr", "clauses"]));
|
|
41
|
-
},
|
|
42
|
-
constraint_collate: function (print) {
|
|
43
|
-
return (0, print_utils_1.group)(print.spaced(["collateKw", "collation"]));
|
|
44
|
-
},
|
|
45
|
-
constraint_foreign_key: function (print) {
|
|
46
|
-
return (0, print_utils_1.group)(print.spaced(["foreignKeyKw", "indexName", "columns", "references"]));
|
|
47
|
-
},
|
|
48
|
-
references_specification: function (print, node) {
|
|
49
|
-
var baseDoc = print.spaced(["referencesKw", "table", "columns"]);
|
|
15
|
+
constraint_name: (print) => print.spaced(["constraintKw", "name"]),
|
|
16
|
+
constraint_modifier: (print) => print.spaced("kw"),
|
|
17
|
+
constraint_null: (print) => print("nullKw"),
|
|
18
|
+
constraint_not_null: (print) => group(print.spaced(["notNullKw", "clauses"])),
|
|
19
|
+
constraint_default: (print) => group(print.spaced(["defaultKw", "expr"])),
|
|
20
|
+
constraint_primary_key: (print) => group(print.spaced(["primaryKeyKw", "direction", "columns", "clauses"])),
|
|
21
|
+
constraint_unique: (print) => group(print.spaced(["uniqueKw", "columns", "nullsKw", "clauses"])),
|
|
22
|
+
existing_index: (print) => print.spaced(["usingIndexKw", "index"]),
|
|
23
|
+
constraint_check: (print) => group(print.spaced(["checkKw", "expr", "clauses"])),
|
|
24
|
+
constraint_collate: (print) => group(print.spaced(["collateKw", "collation"])),
|
|
25
|
+
constraint_foreign_key: (print) => group(print.spaced(["foreignKeyKw", "indexName", "columns", "references"])),
|
|
26
|
+
references_specification: (print, node) => {
|
|
27
|
+
const baseDoc = print.spaced(["referencesKw", "table", "columns"]);
|
|
50
28
|
if (node.options.length > 0) {
|
|
51
|
-
return
|
|
29
|
+
return group([
|
|
52
30
|
baseDoc,
|
|
53
|
-
|
|
31
|
+
indent([hardline, join(hardline, print("options"))]),
|
|
54
32
|
]);
|
|
55
33
|
}
|
|
56
34
|
else {
|
|
57
35
|
return baseDoc;
|
|
58
36
|
}
|
|
59
37
|
},
|
|
60
|
-
referential_action:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return (0, print_utils_1.join)(node.hasEq ? " = " : " ", print(["engineAttributeKw", "value"]));
|
|
87
|
-
},
|
|
88
|
-
constraint_compression: function (print) { return print.spaced(["compressionKw", "method"]); },
|
|
89
|
-
constraint_exclude: function (print, node) {
|
|
90
|
-
return (0, print_utils_1.group)([
|
|
91
|
-
print("excludeKw"),
|
|
92
|
-
(0, print_utils_1.indent)([
|
|
93
|
-
print_utils_1.line,
|
|
94
|
-
(0, print_utils_1.join)(print_utils_1.line, __spreadArray([
|
|
95
|
-
print.separated(print_utils_1.line, ["using", "params"])
|
|
96
|
-
], print("clauses"), true)),
|
|
38
|
+
referential_action: (print) => print.spaced(["onKw", "eventKw", "actionKw", "columns"]),
|
|
39
|
+
referential_match: (print) => print.spaced(["matchKw", "typeKw"]),
|
|
40
|
+
constraint_generated: (print) => print.spaced([
|
|
41
|
+
"generatedKw",
|
|
42
|
+
"asKw",
|
|
43
|
+
"expr",
|
|
44
|
+
"storageKw",
|
|
45
|
+
"sequenceOptions",
|
|
46
|
+
]),
|
|
47
|
+
identity_column: (print) => print("identityKw"),
|
|
48
|
+
constraint_auto_increment: (print) => print("autoIncrementKw"),
|
|
49
|
+
on_conflict_clause: (print) => print.spaced(["onConflictKw", "resolutionKw"]),
|
|
50
|
+
constraint_comment: (print) => print.spaced(["commentKw", "value"]),
|
|
51
|
+
constraint_index: (print) => print.spaced(["indexTypeKw", "indexKw", "columns"]),
|
|
52
|
+
constraint_visible: (print) => print.spaced(["visibleKw"]),
|
|
53
|
+
constraint_column_format: (print) => print.spaced(["columnFormatKw", "formatKw"]),
|
|
54
|
+
constraint_storage: (print) => print.spaced(["storageKw", "typeKw"]),
|
|
55
|
+
constraint_engine_attribute: (print, node) => join(node.hasEq ? " = " : " ", print(["engineAttributeKw", "value"])),
|
|
56
|
+
constraint_compression: (print) => print.spaced(["compressionKw", "method"]),
|
|
57
|
+
constraint_exclude: (print, node) => group([
|
|
58
|
+
print("excludeKw"),
|
|
59
|
+
indent([
|
|
60
|
+
line,
|
|
61
|
+
join(line, [
|
|
62
|
+
print.separated(line, ["using", "params"]),
|
|
63
|
+
...print("clauses"),
|
|
97
64
|
]),
|
|
98
|
-
])
|
|
99
|
-
|
|
100
|
-
exclusion_param:
|
|
101
|
-
index_tablespace_clause:
|
|
102
|
-
return print.spaced(["usingIndexTablespaceKw", "name"]);
|
|
103
|
-
},
|
|
65
|
+
]),
|
|
66
|
+
]),
|
|
67
|
+
exclusion_param: (print) => print.spaced(["index", "withKw", "operator"]),
|
|
68
|
+
index_tablespace_clause: (print) => print.spaced(["usingIndexTablespaceKw", "name"]),
|
|
104
69
|
};
|
|
105
|
-
|
|
70
|
+
export const printUnnamedConstraint = (print, node) => {
|
|
106
71
|
if (node.modifiers.length > 0) {
|
|
107
|
-
return
|
|
72
|
+
return group([
|
|
108
73
|
print("constraint"),
|
|
109
|
-
|
|
74
|
+
indent([line, print.spaced("modifiers")]),
|
|
110
75
|
]);
|
|
111
76
|
}
|
|
112
77
|
else {
|
|
113
78
|
return print("constraint");
|
|
114
79
|
}
|
|
115
80
|
};
|
|
116
|
-
exports.printUnnamedConstraint = printUnnamedConstraint;
|
|
@@ -1,45 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createTableMap = void 0;
|
|
13
|
-
var node_utils_1 = require("../node_utils");
|
|
14
|
-
var print_utils_1 = require("../print_utils");
|
|
15
|
-
exports.createTableMap = {
|
|
1
|
+
import { isAsClause } from "../node_utils";
|
|
2
|
+
import { group, join, line } from "../print_utils";
|
|
3
|
+
export const createTableMap = {
|
|
16
4
|
/** cst-ignore: clauses */
|
|
17
|
-
create_table_stmt:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
node.options ? [print_utils_1.line, (0, print_utils_1.group)(print("options"))] : [],
|
|
36
|
-
]);
|
|
37
|
-
},
|
|
38
|
-
relation_kind: function (print) { return print.spaced("kindKw"); },
|
|
39
|
-
column_definition: function (print) {
|
|
40
|
-
return print.spaced(["name", "dataType", "withOptionsKw", "constraints"]);
|
|
41
|
-
},
|
|
42
|
-
table_option: function (print, node) {
|
|
5
|
+
create_table_stmt: (print, node, ...rest) => group([
|
|
6
|
+
print.spaced([
|
|
7
|
+
"createKw",
|
|
8
|
+
"orReplaceKw",
|
|
9
|
+
"kind",
|
|
10
|
+
"tableKw",
|
|
11
|
+
"ifNotExistsKw",
|
|
12
|
+
"name",
|
|
13
|
+
"partitionOf",
|
|
14
|
+
"ofType",
|
|
15
|
+
"columns",
|
|
16
|
+
]),
|
|
17
|
+
printClauses(print, node, ...rest),
|
|
18
|
+
node.options ? [line, group(print("options"))] : [],
|
|
19
|
+
]),
|
|
20
|
+
relation_kind: (print) => print.spaced("kindKw"),
|
|
21
|
+
column_definition: (print) => print.spaced(["name", "dataType", "withOptionsKw", "constraints"]),
|
|
22
|
+
table_option: (print, node) => {
|
|
43
23
|
if (node.value && node.hasEq) {
|
|
44
24
|
return [print.spaced("name"), " = ", print.spaced("value")];
|
|
45
25
|
}
|
|
@@ -50,56 +30,38 @@ exports.createTableMap = {
|
|
|
50
30
|
return print.spaced("name");
|
|
51
31
|
}
|
|
52
32
|
},
|
|
53
|
-
create_table_like_clause:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
partition_bound_from_to: function (print) {
|
|
79
|
-
return print.spaced(["fromKw", "from", "toKw", "to"]);
|
|
80
|
-
},
|
|
81
|
-
partition_bound_minvalue: function (print) { return print.spaced("minvalueKw"); },
|
|
82
|
-
partition_bound_maxvalue: function (print) { return print.spaced("maxvalueKw"); },
|
|
83
|
-
partition_bound_with: function (print) { return print.spaced(["withKw", "values"]); },
|
|
84
|
-
partition_bound_modulus: function (print) { return print.spaced(["modulusKw", "value"]); },
|
|
85
|
-
partition_bound_remainder: function (print) { return print.spaced(["remainderKw", "value"]); },
|
|
86
|
-
create_table_default_partition_clause: function (print) { return print.spaced("defaultKw"); },
|
|
87
|
-
create_table_of_type_clause: function (print) { return print.spaced(["ofKw", "typeName"]); },
|
|
88
|
-
using_access_method_clause: function (print) { return print.spaced(["usingKw", "method"]); },
|
|
89
|
-
tablespace_clause: function (print) { return print.spaced(["tablespaceKw", "name"]); },
|
|
90
|
-
create_table_without_oids_clause: function (print) { return print.spaced("withoutOidsKw"); },
|
|
91
|
-
create_table_on_commit_clause: function (print) {
|
|
92
|
-
return print.spaced(["onCommitKw", "actionKw"]);
|
|
93
|
-
},
|
|
94
|
-
with_data_clause: function (print) { return print.spaced("withDataKw"); },
|
|
95
|
-
create_table_server_clause: function (print) { return print.spaced(["serverKw", "name"]); },
|
|
33
|
+
create_table_like_clause: (print) => print.spaced(["likeKw", "name", "options"]),
|
|
34
|
+
table_like_option: (print) => print.spaced(["includingOrExcludingKw", "optionKw"]),
|
|
35
|
+
create_table_copy_clause: (print) => print.spaced(["copyKw", "name"]),
|
|
36
|
+
create_table_clone_clause: (print) => print.spaced(["cloneKw", "table"]),
|
|
37
|
+
with_partition_columns_clause: (print) => print.spaced(["withPartitionColumnsKw", "columns"]),
|
|
38
|
+
create_table_using_clause: (print) => print.spaced(["usingKw", "module"]),
|
|
39
|
+
create_table_inherits_clause: (print) => print.spaced(["inheritsKw", "tables"]),
|
|
40
|
+
create_table_partition_by_clause: (print) => print.spaced(["partitionByKw", "strategyKw", "columns"]),
|
|
41
|
+
create_table_partition_of_clause: (print) => print.spaced(["partitionOfKw", "table"]),
|
|
42
|
+
create_table_partition_bound_clause: (print) => print.spaced(["forValuesKw", "bound"]),
|
|
43
|
+
partition_bound_in: (print) => print.spaced(["inKw", "values"]),
|
|
44
|
+
partition_bound_from_to: (print) => print.spaced(["fromKw", "from", "toKw", "to"]),
|
|
45
|
+
partition_bound_minvalue: (print) => print.spaced("minvalueKw"),
|
|
46
|
+
partition_bound_maxvalue: (print) => print.spaced("maxvalueKw"),
|
|
47
|
+
partition_bound_with: (print) => print.spaced(["withKw", "values"]),
|
|
48
|
+
partition_bound_modulus: (print) => print.spaced(["modulusKw", "value"]),
|
|
49
|
+
partition_bound_remainder: (print) => print.spaced(["remainderKw", "value"]),
|
|
50
|
+
create_table_default_partition_clause: (print) => print.spaced("defaultKw"),
|
|
51
|
+
create_table_of_type_clause: (print) => print.spaced(["ofKw", "typeName"]),
|
|
52
|
+
using_access_method_clause: (print) => print.spaced(["usingKw", "method"]),
|
|
53
|
+
tablespace_clause: (print) => print.spaced(["tablespaceKw", "name"]),
|
|
54
|
+
create_table_without_oids_clause: (print) => print.spaced("withoutOidsKw"),
|
|
55
|
+
create_table_on_commit_clause: (print) => print.spaced(["onCommitKw", "actionKw"]),
|
|
56
|
+
with_data_clause: (print) => print.spaced("withDataKw"),
|
|
57
|
+
create_table_server_clause: (print) => print.spaced(["serverKw", "name"]),
|
|
96
58
|
};
|
|
97
|
-
|
|
98
|
-
if (node.clauses.length === 1 &&
|
|
59
|
+
const printClauses = (print, node) => {
|
|
60
|
+
if (node.clauses.length === 1 && isAsClause(node.clauses[0])) {
|
|
99
61
|
return [" ", print("clauses")];
|
|
100
62
|
}
|
|
101
63
|
else if (node.clauses.length > 0) {
|
|
102
|
-
return [
|
|
64
|
+
return [line, join(line, print("clauses"))];
|
|
103
65
|
}
|
|
104
66
|
else {
|
|
105
67
|
return [];
|
package/dist/syntax/data_type.js
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.dataTypeMap = void 0;
|
|
13
|
-
var utils_1 = require("../utils");
|
|
14
|
-
var print_utils_1 = require("../print_utils");
|
|
15
|
-
var node_utils_1 = require("../node_utils");
|
|
16
|
-
exports.dataTypeMap = {
|
|
17
|
-
data_type_name: function (print) { return print.spaced("name"); },
|
|
1
|
+
import { isArray } from "../utils";
|
|
2
|
+
import { group, indent, join, softline } from "../print_utils";
|
|
3
|
+
import { isDataTypeName } from "../node_utils";
|
|
4
|
+
export const dataTypeMap = {
|
|
5
|
+
data_type_name: (print) => print.spaced("name"),
|
|
18
6
|
// print single-word types as `TYPE(10)` and multi-word types as `MY TYPE (10)`
|
|
19
|
-
modified_data_type:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return (0, print_utils_1.group)(["<", (0, print_utils_1.indent)([print_utils_1.softline, print("params")]), print_utils_1.softline, ">"]);
|
|
39
|
-
},
|
|
40
|
-
array_type_param: function (print) { return print.spaced(["dataType", "constraints"]); },
|
|
41
|
-
struct_type_param: function (print) {
|
|
42
|
-
return print.spaced(["name", "dataType", "constraints"]);
|
|
43
|
-
},
|
|
44
|
-
table_data_type: function (print) { return print.spaced(["tableKw", "columns"]); },
|
|
7
|
+
modified_data_type: (print, node) => (isMultiWordTypeName(node.dataType) ? print.spaced : print)([
|
|
8
|
+
"dataType",
|
|
9
|
+
"modifiers",
|
|
10
|
+
]),
|
|
11
|
+
setof_data_type: (print) => print.spaced(["setofKw", "dataType"]),
|
|
12
|
+
array_data_type: (print) => print(["dataType", "bounds"]),
|
|
13
|
+
array_bounds: (print) => ["[", print("bounds"), "]"],
|
|
14
|
+
time_data_type: (print, node) => group(join(" ", [
|
|
15
|
+
print(["timeKw", "precision"]),
|
|
16
|
+
...(node.timeZoneKw ? [print.spaced("timeZoneKw")] : []),
|
|
17
|
+
])),
|
|
18
|
+
interval_data_type: (print) => print.spaced(["intervalKw", "unit"]),
|
|
19
|
+
interval_unit_range: (print) => print.spaced(["fromUnit", "toKw", "toUnit"]),
|
|
20
|
+
interval_unit: (print) => print.spaced(["unitKw", "precision"]),
|
|
21
|
+
parametric_data_type: (print) => print(["typeKw", "params"]),
|
|
22
|
+
generic_type_params: (print) => group(["<", indent([softline, print("params")]), softline, ">"]),
|
|
23
|
+
array_type_param: (print) => print.spaced(["dataType", "constraints"]),
|
|
24
|
+
struct_type_param: (print) => print.spaced(["name", "dataType", "constraints"]),
|
|
25
|
+
table_data_type: (print) => print.spaced(["tableKw", "columns"]),
|
|
45
26
|
};
|
|
46
27
|
function isMultiWordTypeName(node) {
|
|
47
|
-
return
|
|
28
|
+
return isDataTypeName(node) && isArray(node.name) && node.name.length > 1;
|
|
48
29
|
}
|