prettier-plugin-sql-cst 0.19.2 → 0.19.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.
Files changed (145) hide show
  1. package/dist/index.d.ts +21 -7
  2. package/dist/index.js +2637 -55
  3. package/package.json +3 -2
  4. package/dist/CstToDocMap.d.ts +0 -11
  5. package/dist/CstToDocMap.js +0 -1
  6. package/dist/PrintFn.d.ts +0 -17
  7. package/dist/PrintFn.js +0 -1
  8. package/dist/embed.d.ts +0 -3
  9. package/dist/embed.js +0 -6
  10. package/dist/embedJs.d.ts +0 -3
  11. package/dist/embedJs.js +0 -43
  12. package/dist/embedJson.d.ts +0 -3
  13. package/dist/embedJson.js +0 -34
  14. package/dist/embedSql.d.ts +0 -3
  15. package/dist/embedSql.js +0 -39
  16. package/dist/node_utils.d.ts +0 -38
  17. package/dist/node_utils.js +0 -44
  18. package/dist/options.d.ts +0 -15
  19. package/dist/options.js +0 -147
  20. package/dist/printComment.d.ts +0 -3
  21. package/dist/printComment.js +0 -12
  22. package/dist/printSql.d.ts +0 -5
  23. package/dist/printSql.js +0 -61
  24. package/dist/print_utils.d.ts +0 -13
  25. package/dist/print_utils.js +0 -49
  26. package/dist/syntax/alias.d.ts +0 -3
  27. package/dist/syntax/alias.js +0 -3
  28. package/dist/syntax/alter_action.d.ts +0 -3
  29. package/dist/syntax/alter_action.js +0 -120
  30. package/dist/syntax/alter_table.d.ts +0 -3
  31. package/dist/syntax/alter_table.js +0 -19
  32. package/dist/syntax/analyze.d.ts +0 -3
  33. package/dist/syntax/analyze.js +0 -4
  34. package/dist/syntax/base.d.ts +0 -3
  35. package/dist/syntax/base.js +0 -19
  36. package/dist/syntax/cast.d.ts +0 -3
  37. package/dist/syntax/cast.js +0 -4
  38. package/dist/syntax/comment.d.ts +0 -3
  39. package/dist/syntax/comment.js +0 -54
  40. package/dist/syntax/constraint.d.ts +0 -6
  41. package/dist/syntax/constraint.js +0 -80
  42. package/dist/syntax/create_table.d.ts +0 -3
  43. package/dist/syntax/create_table.js +0 -69
  44. package/dist/syntax/data_type.d.ts +0 -3
  45. package/dist/syntax/data_type.js +0 -29
  46. package/dist/syntax/dcl.d.ts +0 -3
  47. package/dist/syntax/dcl.js +0 -83
  48. package/dist/syntax/delete.d.ts +0 -3
  49. package/dist/syntax/delete.js +0 -5
  50. package/dist/syntax/dialects/bigquery.d.ts +0 -3
  51. package/dist/syntax/dialects/bigquery.js +0 -84
  52. package/dist/syntax/dialects/mysql.d.ts +0 -3
  53. package/dist/syntax/dialects/mysql.js +0 -3
  54. package/dist/syntax/dialects/postgresql.d.ts +0 -3
  55. package/dist/syntax/dialects/postgresql.js +0 -9
  56. package/dist/syntax/dialects/sqlite.d.ts +0 -3
  57. package/dist/syntax/dialects/sqlite.js +0 -9
  58. package/dist/syntax/do.d.ts +0 -3
  59. package/dist/syntax/do.js +0 -4
  60. package/dist/syntax/domain.d.ts +0 -3
  61. package/dist/syntax/domain.js +0 -11
  62. package/dist/syntax/drop_table.d.ts +0 -3
  63. package/dist/syntax/drop_table.js +0 -11
  64. package/dist/syntax/explain.d.ts +0 -3
  65. package/dist/syntax/explain.js +0 -7
  66. package/dist/syntax/expr.d.ts +0 -5
  67. package/dist/syntax/expr.js +0 -224
  68. package/dist/syntax/extension.d.ts +0 -3
  69. package/dist/syntax/extension.js +0 -13
  70. package/dist/syntax/frame.d.ts +0 -3
  71. package/dist/syntax/frame.js +0 -13
  72. package/dist/syntax/function.d.ts +0 -4
  73. package/dist/syntax/function.js +0 -55
  74. package/dist/syntax/index.d.ts +0 -3
  75. package/dist/syntax/index.js +0 -60
  76. package/dist/syntax/insert.d.ts +0 -3
  77. package/dist/syntax/insert.js +0 -33
  78. package/dist/syntax/merge.d.ts +0 -3
  79. package/dist/syntax/merge.js +0 -30
  80. package/dist/syntax/other_clauses.d.ts +0 -3
  81. package/dist/syntax/other_clauses.js +0 -9
  82. package/dist/syntax/parameter.d.ts +0 -3
  83. package/dist/syntax/parameter.js +0 -18
  84. package/dist/syntax/policy.d.ts +0 -3
  85. package/dist/syntax/policy.js +0 -27
  86. package/dist/syntax/prepared_statements.d.ts +0 -3
  87. package/dist/syntax/prepared_statements.js +0 -31
  88. package/dist/syntax/proc_clause.d.ts +0 -3
  89. package/dist/syntax/proc_clause.js +0 -14
  90. package/dist/syntax/procedural_language.d.ts +0 -3
  91. package/dist/syntax/procedural_language.js +0 -104
  92. package/dist/syntax/procedure.d.ts +0 -3
  93. package/dist/syntax/procedure.js +0 -38
  94. package/dist/syntax/program.d.ts +0 -3
  95. package/dist/syntax/program.js +0 -39
  96. package/dist/syntax/publication.d.ts +0 -3
  97. package/dist/syntax/publication.js +0 -27
  98. package/dist/syntax/rename_table.d.ts +0 -3
  99. package/dist/syntax/rename_table.js +0 -8
  100. package/dist/syntax/role.d.ts +0 -3
  101. package/dist/syntax/role.js +0 -31
  102. package/dist/syntax/schema.d.ts +0 -3
  103. package/dist/syntax/schema.js +0 -18
  104. package/dist/syntax/select.d.ts +0 -3
  105. package/dist/syntax/select.js +0 -226
  106. package/dist/syntax/sequence.d.ts +0 -3
  107. package/dist/syntax/sequence.js +0 -36
  108. package/dist/syntax/subscription.d.ts +0 -3
  109. package/dist/syntax/subscription.js +0 -10
  110. package/dist/syntax/transaction.d.ts +0 -3
  111. package/dist/syntax/transaction.js +0 -19
  112. package/dist/syntax/transformMap.d.ts +0 -3
  113. package/dist/syntax/transformMap.js +0 -100
  114. package/dist/syntax/trigger.d.ts +0 -3
  115. package/dist/syntax/trigger.js +0 -52
  116. package/dist/syntax/truncate.d.ts +0 -3
  117. package/dist/syntax/truncate.js +0 -10
  118. package/dist/syntax/type.d.ts +0 -3
  119. package/dist/syntax/type.js +0 -12
  120. package/dist/syntax/unsupported_grammar.d.ts +0 -3
  121. package/dist/syntax/unsupported_grammar.js +0 -4
  122. package/dist/syntax/update.d.ts +0 -3
  123. package/dist/syntax/update.js +0 -14
  124. package/dist/syntax/view.d.ts +0 -3
  125. package/dist/syntax/view.js +0 -48
  126. package/dist/transform/addFinalSemicolon.d.ts +0 -2
  127. package/dist/transform/addFinalSemicolon.js +0 -9
  128. package/dist/transform/aliasAs.d.ts +0 -2
  129. package/dist/transform/aliasAs.js +0 -10
  130. package/dist/transform/canonicKeywords.d.ts +0 -2
  131. package/dist/transform/canonicKeywords.js +0 -62
  132. package/dist/transform/canonicOperators.d.ts +0 -3
  133. package/dist/transform/canonicOperators.js +0 -28
  134. package/dist/transform/comments.d.ts +0 -12
  135. package/dist/transform/comments.js +0 -22
  136. package/dist/transform/stripTrailingCommas.d.ts +0 -2
  137. package/dist/transform/stripTrailingCommas.js +0 -15
  138. package/dist/transform/transformCst.d.ts +0 -5
  139. package/dist/transform/transformCst.js +0 -21
  140. package/dist/transform/transformUtils.d.ts +0 -2
  141. package/dist/transform/transformUtils.js +0 -3
  142. package/dist/utils.d.ts +0 -9
  143. package/dist/utils.js +0 -9
  144. package/dist/visitAllNodes.d.ts +0 -2
  145. package/dist/visitAllNodes.js +0 -16
@@ -1,120 +0,0 @@
1
- import { group, indent, join, line } from "../print_utils";
2
- import { printUnnamedConstraint } from "./constraint";
3
- export const alterActionMap = {
4
- alter_action_rename: (print) => print.spaced(["renameKw", "newName"]),
5
- alter_action_rename_column: (print) => print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]),
6
- alter_action_add_column: (print) => print.spaced(["addKw", "ifNotExistsKw", "column"]),
7
- alter_action_drop_column: (print) => print.spaced(["dropKw", "ifExistsKw", "column", "behaviorKw"]),
8
- alter_action_set_bigquery_options: (print) => print.spaced(["setKw", "options"]),
9
- alter_action_set_default_collate: (print) => print.spaced(["setDefaultCollateKw", "collation"]),
10
- /** cst-ignore: constraint, modifiers */
11
- alter_action_add_constraint: (print, node) => group([
12
- print.spaced(["addKw", "name"]),
13
- indent([line, printUnnamedConstraint(print, node)]),
14
- ]),
15
- alter_action_add_constraint_constraint_name: (print) => print.spaced(["constraintKw", "ifNotExistsKw", "name"]),
16
- alter_action_drop_constraint: (print) => print.spaced([
17
- "dropConstraintKw",
18
- "ifExistsKw",
19
- "constraint",
20
- "behaviorKw",
21
- ]),
22
- alter_action_drop_primary_key: (print) => print.spaced(["dropPrimaryKeyKw", "ifExistsKw"]),
23
- alter_action_alter_constraint: (print) => print.spaced(["alterConstraintKw", "constraint", "modifiers"]),
24
- alter_action_rename_constraint: (print) => print.spaced(["renameConstraintKw", "oldName", "toKw", "newName"]),
25
- alter_action_validate_constraint: (print) => print.spaced(["validateConstraintKw", "constraint"]),
26
- alter_action_set_visible: (print) => print.spaced("setVisibleKw"),
27
- alter_action_set_invisible: (print) => print.spaced("setInvisibleKw"),
28
- alter_action_set_tablespace: (print) => print.spaced(["setTablespaceKw", "tablespace", "nowaitKw"]),
29
- alter_action_set_schema: (print) => print.spaced(["setSchemaKw", "schema"]),
30
- alter_action_enable: (print) => print.spaced(["enableKw", "modeKw", "item"]),
31
- alter_action_disable: (print) => print.spaced(["disableKw", "item"]),
32
- alter_action_force: (print) => print.spaced(["forceKw", "item"]),
33
- alter_action_no_force: (print) => print.spaced(["noForceKw", "item"]),
34
- alter_action_cluster_on: (print) => print.spaced(["clusterOnKw", "index"]),
35
- alter_action_set_without_cluster: (print) => print.spaced("setWithoutClusterKw"),
36
- alter_action_set_without_oids: (print) => print.spaced("setWithoutOidsKw"),
37
- alter_action_set_access_method: (print) => print.spaced(["setAccessMethodKw", "method"]),
38
- alter_action_set_logged: (print) => print.spaced("setLoggedKw"),
39
- alter_action_set_unlogged: (print) => print.spaced("setUnloggedKw"),
40
- alter_action_inherit: (print) => print.spaced(["inheritKw", "table"]),
41
- alter_action_no_inherit: (print) => print.spaced(["noInheritKw", "table"]),
42
- alter_action_of_type: (print) => print.spaced(["ofKw", "typeName"]),
43
- alter_action_not_of_type: (print) => print.spaced("notOfKw"),
44
- alter_action_owner_to: (print) => print.spaced(["ownerToKw", "owner"]),
45
- alter_action_replica_identity: (print) => print.spaced(["replicaIdentityKw", "identity"]),
46
- replica_identity_using_index: (print) => print.spaced(["usingIndexKw", "index"]),
47
- alter_action_set_postgresql_options: (print) => print.spaced(["setKw", "options"]),
48
- alter_action_reset_postgresql_options: (print) => print.spaced(["resetKw", "options"]),
49
- alter_action_depends_on_extension: (print) => print.spaced(["dependsOnExtensionKw", "extension"]),
50
- alter_action_no_depends_on_extension: (print) => print.spaced(["noDependsOnExtensionKw", "extension"]),
51
- alter_action_attach_partition: (print) => print.spaced(["attachPartitionKw", "index"]),
52
- alter_action_add_enum_value: (print) => print.spaced(["addValueKw", "ifNotExistsKw", "value", "position"]),
53
- alter_action_add_enum_value_position: (print) => print.spaced(["positionKw", "value"]),
54
- alter_action_rename_enum_value: (print) => print.spaced(["renameValueKw", "oldValue", "toKw", "newValue"]),
55
- alter_action_add_attribute: (print) => print.spaced([
56
- "addAttributeKw",
57
- "name",
58
- "dataType",
59
- "constraint",
60
- "behaviorKw",
61
- ]),
62
- alter_action_drop_attribute: (print) => print.spaced(["dropAttributeKw", "ifExistsKw", "name", "behaviorKw"]),
63
- alter_action_alter_attribute: (print) => print.spaced([
64
- "alterAttributeKw",
65
- "name",
66
- "setDataTypeKw",
67
- "dataType",
68
- "constraint",
69
- "behaviorKw",
70
- ]),
71
- alter_action_rename_attribute: (print) => print.spaced([
72
- "renameAttributeKw",
73
- "oldName",
74
- "toKw",
75
- "newName",
76
- "behaviorKw",
77
- ]),
78
- // ALTER COLUMN
79
- alter_action_alter_column: (print) => group([
80
- print.spaced(["alterKw", "ifExistsKw", "column"]),
81
- print.dynamicLine(),
82
- print("action"),
83
- ]),
84
- alter_action_set_default: (print) => print.spaced(["setDefaultKw", "expr"]),
85
- alter_action_drop_default: (print) => print.spaced("dropDefaultKw"),
86
- alter_action_set_not_null: (print) => print.spaced("setNotNullKw"),
87
- alter_action_drop_not_null: (print) => print.spaced("dropNotNullKw"),
88
- alter_action_set_data_type: (print) => print.spaced(["setDataTypeKw", "dataType", "clauses"]),
89
- alter_action_set_statistics: (print) => print.spaced(["setStatisticsKw", "value"]),
90
- alter_action_set_compression: (print) => print.spaced(["setCompressionKw", "method"]),
91
- alter_action_set_storage: (print) => print.spaced(["setStorageKw", "typeKw"]),
92
- alter_action_drop_expression: (print) => print.spaced(["dropExpressionKw", "ifExistsKw"]),
93
- alter_action_drop_identity: (print) => print.spaced(["dropIdentityKw", "ifExistsKw"]),
94
- alter_action_add_identity: (print) => print.spaced([
95
- "addGeneratedKw",
96
- "whenKw",
97
- "asIdentityKw",
98
- "sequenceOptions",
99
- ]),
100
- alter_action_alter_identity: (print) => group(join(line, print("actions"))),
101
- alter_action_set_generated: (print) => print.spaced(["setGeneratedKw", "whenKw"]),
102
- alter_action_restart: (print) => print.spaced(["restartKw", "withKw", "value"]),
103
- alter_action_set_sequence_option: (print) => print.spaced(["setKw", "option"]),
104
- alter_action_with_role_options: (print, node) => node.withKw
105
- ? group([print("withKw"), indent([line, join(line, print("options"))])])
106
- : // This works in tandem with the logic inside alter_role_stmt
107
- group(join(line, print("options"))),
108
- alter_action_set_postgresql_option: (print) => print.spaced(["setKw", "name", "operator", "value"]),
109
- alter_action_set_postgresql_option_from_current: (print) => print.spaced(["setKw", "name", "fromCurrentKw"]),
110
- alter_action_reset_postgresql_option: (print) => print.spaced(["resetKw", "name"]),
111
- alter_action_add_user: (print) => group(print.spaced(["addUserKw", "users"])),
112
- alter_action_drop_user: (print) => group(print.spaced(["dropUserKw", "users"])),
113
- // ENABLE/DISABLE ..
114
- toggle_trigger: (print) => print.spaced(["triggerKw", "name"]),
115
- toggle_rule: (print) => print.spaced(["ruleKw", "name"]),
116
- toggle_row_level_security: (print) => print.spaced("rowLevelSecurityKw"),
117
- // SET DATA TYPE ...
118
- set_data_type_collate_clause: (print) => print.spaced(["collateKw", "collation"]),
119
- set_data_type_using_clause: (print) => print.spaced(["usingKw", "expr"]),
120
- };
@@ -1,3 +0,0 @@
1
- import { AllAlterTableNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const alterTableMap: CstToDocMap<AllAlterTableNodes>;
@@ -1,19 +0,0 @@
1
- import { group, indent, line } from "../print_utils";
2
- export const alterTableMap = {
3
- alter_table_stmt: (print) => group([
4
- print.spaced(["alterTableKw", "ifExistsKw", "table"]),
5
- print.dynamicLine(),
6
- print("actions"),
7
- ]),
8
- alter_table_all_in_tablespace_stmt: (print) => group([
9
- print.spaced([
10
- "alterTableKw",
11
- "allInTablespaceKw",
12
- "tablespace",
13
- "ownedBy",
14
- ]),
15
- print.dynamicLine(),
16
- print("action"),
17
- ]),
18
- owned_by_clause: (print) => group([print.spaced("ownedByKw"), indent([line, print("owners")])]),
19
- };
@@ -1,3 +0,0 @@
1
- import { AnalyzeStmt } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const analyzeMap: CstToDocMap<AnalyzeStmt>;
@@ -1,4 +0,0 @@
1
- import { group } from "../print_utils";
2
- export const analyzeMap = {
3
- analyze_stmt: (print) => group(print.spaced(["analyzeKw", "tableKw", "tables"])),
4
- };
@@ -1,3 +0,0 @@
1
- import { AllColumns, Empty, Keyword } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const baseMap: CstToDocMap<Keyword | Empty | AllColumns>;
@@ -1,19 +0,0 @@
1
- import { isDataType } from "../node_utils";
2
- export const baseMap = {
3
- /** cst-ignore: name */
4
- keyword: (print, node, path, options) => {
5
- const keywordCase = isDataType(path.ancestors)
6
- ? options.sqlTypeCase
7
- : options.sqlKeywordCase;
8
- switch (keywordCase) {
9
- case "preserve":
10
- return path.node.text;
11
- case "upper":
12
- return path.node.text.toUpperCase();
13
- case "lower":
14
- return path.node.text.toLowerCase();
15
- }
16
- },
17
- all_columns: () => "*",
18
- empty: () => [],
19
- };
@@ -1,3 +0,0 @@
1
- import { AllCastNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const castMap: CstToDocMap<AllCastNodes>;
@@ -1,4 +0,0 @@
1
- import { group } from "../print_utils";
2
- export const castMap = {
3
- cast_definition: (print) => group(print.spaced(["from", "asKw", "to"])),
4
- };
@@ -1,3 +0,0 @@
1
- import { AllCommentNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const commentMap: CstToDocMap<AllCommentNodes>;
@@ -1,54 +0,0 @@
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"])),
54
- };
@@ -1,6 +0,0 @@
1
- import { Doc } from "prettier";
2
- import { AllConstraintNodes, AlterActionAddConstraint, Constraint } from "sql-parser-cst";
3
- import { CstToDocMap } from "../CstToDocMap";
4
- import { PrintFn } from "../PrintFn";
5
- export declare const constraintMap: CstToDocMap<AllConstraintNodes>;
6
- export declare const printUnnamedConstraint: <T>(print: PrintFn<Constraint<T>> | PrintFn<AlterActionAddConstraint>, node: Constraint<T> | AlterActionAddConstraint) => Doc;
@@ -1,80 +0,0 @@
1
- import { group, indent, line, hardline, join } from "../print_utils";
2
- export const constraintMap = {
3
- /** cst-ignore: constraint, modifiers */
4
- constraint: (print, node) => {
5
- if (node.name) {
6
- return group([
7
- print("name"),
8
- indent([line, printUnnamedConstraint(print, node)]),
9
- ]);
10
- }
11
- else {
12
- return printUnnamedConstraint(print, node);
13
- }
14
- },
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"]);
28
- if (node.options.length > 0) {
29
- return group([
30
- baseDoc,
31
- indent([hardline, join(hardline, print("options"))]),
32
- ]);
33
- }
34
- else {
35
- return baseDoc;
36
- }
37
- },
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"),
64
- ]),
65
- ]),
66
- ]),
67
- exclusion_param: (print) => print.spaced(["index", "withKw", "operator"]),
68
- index_tablespace_clause: (print) => print.spaced(["usingIndexTablespaceKw", "name"]),
69
- };
70
- export const printUnnamedConstraint = (print, node) => {
71
- if (node.modifiers.length > 0) {
72
- return group([
73
- print("constraint"),
74
- indent([line, print.spaced("modifiers")]),
75
- ]);
76
- }
77
- else {
78
- return print("constraint");
79
- }
80
- };
@@ -1,3 +0,0 @@
1
- import { AllCreateTableNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const createTableMap: CstToDocMap<AllCreateTableNodes>;
@@ -1,69 +0,0 @@
1
- import { isAsClause } from "../node_utils";
2
- import { group, join, line } from "../print_utils";
3
- export const createTableMap = {
4
- /** cst-ignore: clauses */
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) => {
23
- if (node.value && node.hasEq) {
24
- return [print.spaced("name"), " = ", print.spaced("value")];
25
- }
26
- else if (node.value) {
27
- return [print.spaced("name"), " ", print.spaced("value")];
28
- }
29
- else {
30
- return print.spaced("name");
31
- }
32
- },
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"]),
58
- };
59
- const printClauses = (print, node) => {
60
- if (node.clauses.length === 1 && isAsClause(node.clauses[0])) {
61
- return [" ", print("clauses")];
62
- }
63
- else if (node.clauses.length > 0) {
64
- return [line, join(line, print("clauses"))];
65
- }
66
- else {
67
- return [];
68
- }
69
- };
@@ -1,3 +0,0 @@
1
- import { AllDataTypeNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const dataTypeMap: CstToDocMap<AllDataTypeNodes>;
@@ -1,29 +0,0 @@
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"),
6
- // print single-word types as `TYPE(10)` and multi-word types as `MY TYPE (10)`
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"]),
26
- };
27
- function isMultiWordTypeName(node) {
28
- return isDataTypeName(node) && isArray(node.name) && node.name.length > 1;
29
- }
@@ -1,3 +0,0 @@
1
- import { AllDclNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const dclMap: CstToDocMap<AllDclNodes>;
@@ -1,83 +0,0 @@
1
- import { group, indent, join, line } from "../print_utils";
2
- export const dclMap = {
3
- grant_privilege_stmt: (print) => group(join(print.dynamicLine(), [
4
- group([print("grantKw"), indent([line, print("privileges")])]),
5
- group(print.spaced(["onKw", "resource"])),
6
- group([print("toKw"), indent([line, print("roles")])]),
7
- ...print("clauses"),
8
- ])),
9
- grant_role_stmt: (print) => group(join(print.dynamicLine(), [
10
- group(join(line, [
11
- group([print("grantKw"), indent([line, print("grantedRoles")])]),
12
- group([print("toKw"), indent([line, print("granteeRoles")])]),
13
- ])),
14
- ...print("clauses"),
15
- ])),
16
- revoke_privilege_stmt: (print) => group(join(print.dynamicLine(), [
17
- group([
18
- print.spaced(["revokeKw", "option"]),
19
- indent([line, print("privileges")]),
20
- ]),
21
- group(print.spaced(["onKw", "resource"])),
22
- group([print("fromKw"), indent([line, print("roles")])]),
23
- ...print(["grantedBy", "behaviorKw"]),
24
- ])),
25
- revoke_role_stmt: (print) => group(join(print.dynamicLine(), [
26
- group(join(line, [
27
- group([
28
- print.spaced(["revokeKw", "option"]),
29
- indent([line, print("grantedRoles")]),
30
- ]),
31
- group([print("fromKw"), indent([line, print("granteeRoles")])]),
32
- ])),
33
- ...print(["grantedBy", "behaviorKw"]),
34
- ])),
35
- privilege: (print) => print.spaced(["privilegeKw", "columns"]),
36
- all_privileges: (print) => print.spaced(["allKw", "privilegesKw", "columns"]),
37
- grant_resource_table: (print) => group(print.spaced(["tableKw", "tables"])),
38
- grant_resource_view: (print) => group(print.spaced(["viewKw", "views"])),
39
- grant_resource_schema: (print) => group(print.spaced(["schemaKw", "schemas"])),
40
- grant_resource_sequence: (print) => group(print.spaced(["sequenceKw", "sequences"])),
41
- grant_resource_database: (print) => group(print.spaced(["databaseKw", "databases"])),
42
- grant_resource_domain: (print) => group(print.spaced(["domainKw", "domains"])),
43
- grant_resource_foreign_data_wrapper: (print) => group(print.spaced(["foreignDataWrapperKw", "dataWrappers"])),
44
- grant_resource_foreign_server: (print) => group(print.spaced(["foreignServerKw", "servers"])),
45
- grant_resource_function: (print) => group(print.spaced(["functionKw", "functions"])),
46
- grant_resource_language: (print) => group(print.spaced(["languageKw", "languages"])),
47
- grant_resource_large_object: (print) => group(print.spaced(["largeObjectKw", "oids"])),
48
- grant_resource_postgresql_option: (print) => group(print.spaced(["parameterKw", "options"])),
49
- grant_resource_tablespace: (print) => group(print.spaced(["tablespaceKw", "tablespaces"])),
50
- grant_resource_type: (print) => group(print.spaced(["typeKw", "types"])),
51
- grant_resource_all_tables_in_schema: (print) => group(print.spaced(["allTablesInSchemaKw", "schemas"])),
52
- grant_resource_all_sequences_in_schema: (print) => group(print.spaced(["allSequencesInSchemaKw", "schemas"])),
53
- grant_resource_all_functions_in_schema: (print) => group(print.spaced(["allFunctionsInSchemaKw", "schemas"])),
54
- with_grant_option_clause: (print) => group(print.spaced(["withKw", "nameKw", "value"])),
55
- grant_option_for_clause: (print) => group(print.spaced(["nameKw", "optionForKw"])),
56
- granted_by_clause: (print) => group(print.spaced(["grantedByKw", "role"])),
57
- grantee_public: (print) => print("publicKw"),
58
- grantee_group: (print) => group(print.spaced(["groupKw", "name"])),
59
- alter_default_privileges_stmt: (print) => group(join(print.dynamicLine(), [
60
- print.spaced("alterDefaultPrivilegesKw"),
61
- ...print("clauses"),
62
- print("action"),
63
- ])),
64
- default_acl_for_role_clause: (print) => group(print.spaced(["forKw", "roleKw", "roles"])),
65
- default_acl_in_schema_clause: (print) => group(print.spaced(["inKw", "schemaKw", "schemas"])),
66
- grant_default_privileges_action: (print) => group(join(line, [
67
- group(print.spaced(["grantKw", "privileges", "onKw", "resourcesKw"])),
68
- group(print.spaced(["toKw", "roles", "withGrantOption"])),
69
- ])),
70
- revoke_default_privileges_action: (print) => group(join(line, [
71
- group([
72
- print.spaced(["revokeKw", "grantOptionFor"]),
73
- indent([
74
- line,
75
- join(line, [
76
- group(print("privileges")),
77
- print.spaced(["onKw", "resourcesKw"]),
78
- ]),
79
- ]),
80
- ]),
81
- group(print.spaced(["fromKw", "roles", "behaviorKw"])),
82
- ])),
83
- };
@@ -1,3 +0,0 @@
1
- import { AllDeleteNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../CstToDocMap";
3
- export declare const deleteMap: CstToDocMap<AllDeleteNodes>;
@@ -1,5 +0,0 @@
1
- import { group, join } from "../print_utils";
2
- export const deleteMap = {
3
- delete_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
4
- delete_clause: (print) => print.spaced(["deleteKw", "modifiers", "fromKw", "tables"]),
5
- };
@@ -1,3 +0,0 @@
1
- import { AllBigqueryNodes } from "sql-parser-cst";
2
- import { CstToDocMap } from "../../CstToDocMap";
3
- export declare const bigqueryMap: CstToDocMap<AllBigqueryNodes>;