prettier-plugin-sql-cst 0.18.0 → 0.19.0

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 (213) hide show
  1. package/dist/{CstToDocMap.d.ts → src/CstToDocMap.d.ts} +2 -2
  2. package/dist/src/CstToDocMap.js +1 -0
  3. package/dist/src/PrintFn.js +1 -0
  4. package/dist/src/embed.js +6 -0
  5. package/dist/src/embedJs.js +43 -0
  6. package/dist/src/embedJson.js +34 -0
  7. package/dist/src/embedSql.js +39 -0
  8. package/dist/src/index.js +64 -0
  9. package/dist/{node_utils.d.ts → src/node_utils.d.ts} +1 -0
  10. package/dist/src/node_utils.js +44 -0
  11. package/dist/{options.js → src/options.js} +1 -4
  12. package/dist/{printComment.js → src/printComment.js} +2 -6
  13. package/dist/src/printSql.js +61 -0
  14. package/dist/src/print_utils.js +49 -0
  15. package/dist/src/syntax/alias.js +3 -0
  16. package/dist/src/syntax/alter_action.js +120 -0
  17. package/dist/src/syntax/alter_table.js +19 -0
  18. package/dist/src/syntax/analyze.js +4 -0
  19. package/dist/{syntax → src/syntax}/base.js +6 -9
  20. package/dist/src/syntax/cast.js +4 -0
  21. package/dist/src/syntax/comment.js +54 -0
  22. package/dist/{syntax → src/syntax}/constraint.d.ts +1 -1
  23. package/dist/src/syntax/constraint.js +80 -0
  24. package/dist/src/syntax/create_table.js +69 -0
  25. package/dist/src/syntax/data_type.js +29 -0
  26. package/dist/src/syntax/dcl.js +83 -0
  27. package/dist/src/syntax/delete.js +5 -0
  28. package/dist/src/syntax/dialects/bigquery.js +84 -0
  29. package/dist/src/syntax/dialects/mysql.js +3 -0
  30. package/dist/src/syntax/dialects/postgresql.js +9 -0
  31. package/dist/src/syntax/dialects/sqlite.js +9 -0
  32. package/dist/src/syntax/do.js +4 -0
  33. package/dist/src/syntax/domain.js +11 -0
  34. package/dist/src/syntax/drop_table.js +11 -0
  35. package/dist/src/syntax/explain.js +7 -0
  36. package/dist/src/syntax/expr.js +224 -0
  37. package/dist/src/syntax/extension.js +13 -0
  38. package/dist/src/syntax/frame.js +13 -0
  39. package/dist/src/syntax/function.js +55 -0
  40. package/dist/src/syntax/index.js +60 -0
  41. package/dist/src/syntax/insert.js +33 -0
  42. package/dist/src/syntax/merge.js +30 -0
  43. package/dist/src/syntax/other_clauses.js +9 -0
  44. package/dist/src/syntax/parameter.js +18 -0
  45. package/dist/src/syntax/policy.js +27 -0
  46. package/dist/src/syntax/prepared_statements.js +31 -0
  47. package/dist/src/syntax/proc_clause.js +14 -0
  48. package/dist/src/syntax/procedural_language.js +104 -0
  49. package/dist/src/syntax/procedure.js +38 -0
  50. package/dist/src/syntax/program.js +39 -0
  51. package/dist/src/syntax/publication.js +27 -0
  52. package/dist/src/syntax/rename_table.js +8 -0
  53. package/dist/src/syntax/role.js +31 -0
  54. package/dist/src/syntax/schema.js +18 -0
  55. package/dist/src/syntax/select.js +226 -0
  56. package/dist/src/syntax/sequence.js +36 -0
  57. package/dist/src/syntax/subscription.js +10 -0
  58. package/dist/src/syntax/transaction.js +19 -0
  59. package/dist/src/syntax/transformMap.js +100 -0
  60. package/dist/src/syntax/trigger.js +52 -0
  61. package/dist/src/syntax/truncate.js +10 -0
  62. package/dist/src/syntax/type.js +12 -0
  63. package/dist/src/syntax/unsupported_grammar.js +4 -0
  64. package/dist/src/syntax/update.js +14 -0
  65. package/dist/src/syntax/view.js +48 -0
  66. package/dist/src/transform/addFinalSemicolon.js +9 -0
  67. package/dist/src/transform/aliasAs.js +10 -0
  68. package/dist/{transform → src/transform}/canonicKeywords.js +16 -20
  69. package/dist/{transform → src/transform}/canonicOperators.js +8 -12
  70. package/dist/src/transform/comments.js +22 -0
  71. package/dist/src/transform/stripTrailingCommas.js +15 -0
  72. package/dist/src/transform/transformCst.js +21 -0
  73. package/dist/src/transform/transformUtils.js +3 -0
  74. package/dist/src/utils.js +9 -0
  75. package/dist/src/visitAllNodes.js +16 -0
  76. package/dist/tsconfig.json +14 -0
  77. package/package.json +9 -8
  78. package/dist/CstToDocMap.js +0 -2
  79. package/dist/PrintFn.js +0 -2
  80. package/dist/embed.js +0 -14
  81. package/dist/embedJs.js +0 -99
  82. package/dist/embedJson.js +0 -90
  83. package/dist/embedSql.js +0 -89
  84. package/dist/index.js +0 -70
  85. package/dist/node_utils.js +0 -54
  86. package/dist/printSql.js +0 -71
  87. package/dist/print_utils.js +0 -68
  88. package/dist/syntax/alias.js +0 -6
  89. package/dist/syntax/alter_action.js +0 -213
  90. package/dist/syntax/alter_table.js +0 -28
  91. package/dist/syntax/analyze.js +0 -9
  92. package/dist/syntax/cast.js +0 -7
  93. package/dist/syntax/comment.js +0 -123
  94. package/dist/syntax/constraint.js +0 -116
  95. package/dist/syntax/create_table.js +0 -107
  96. package/dist/syntax/data_type.js +0 -48
  97. package/dist/syntax/dcl.js +0 -141
  98. package/dist/syntax/delete.js +0 -10
  99. package/dist/syntax/dialects/bigquery.js +0 -130
  100. package/dist/syntax/dialects/mysql.js +0 -6
  101. package/dist/syntax/dialects/postgresql.js +0 -14
  102. package/dist/syntax/dialects/sqlite.js +0 -18
  103. package/dist/syntax/do.js +0 -7
  104. package/dist/syntax/domain.js +0 -20
  105. package/dist/syntax/drop_table.js +0 -16
  106. package/dist/syntax/explain.js +0 -12
  107. package/dist/syntax/expr.js +0 -273
  108. package/dist/syntax/extension.js +0 -22
  109. package/dist/syntax/frame.js +0 -18
  110. package/dist/syntax/function.js +0 -65
  111. package/dist/syntax/index.js +0 -87
  112. package/dist/syntax/insert.js +0 -50
  113. package/dist/syntax/merge.js +0 -35
  114. package/dist/syntax/other_clauses.js +0 -18
  115. package/dist/syntax/parameter.js +0 -31
  116. package/dist/syntax/policy.js +0 -42
  117. package/dist/syntax/prepared_statements.js +0 -51
  118. package/dist/syntax/proc_clause.js +0 -19
  119. package/dist/syntax/procedural_language.js +0 -135
  120. package/dist/syntax/procedure.js +0 -42
  121. package/dist/syntax/program.js +0 -46
  122. package/dist/syntax/publication.js +0 -48
  123. package/dist/syntax/rename_table.js +0 -13
  124. package/dist/syntax/role.js +0 -56
  125. package/dist/syntax/schema.js +0 -36
  126. package/dist/syntax/select.js +0 -295
  127. package/dist/syntax/sequence.js +0 -53
  128. package/dist/syntax/subscription.js +0 -25
  129. package/dist/syntax/transaction.js +0 -34
  130. package/dist/syntax/transformMap.js +0 -64
  131. package/dist/syntax/trigger.js +0 -76
  132. package/dist/syntax/truncate.js +0 -15
  133. package/dist/syntax/type.js +0 -23
  134. package/dist/syntax/unsupported_grammar.js +0 -7
  135. package/dist/syntax/update.js +0 -21
  136. package/dist/syntax/view.js +0 -59
  137. package/dist/transform/addFinalSemicolon.js +0 -13
  138. package/dist/transform/aliasAs.js +0 -14
  139. package/dist/transform/comments.js +0 -43
  140. package/dist/transform/stripTrailingCommas.js +0 -19
  141. package/dist/transform/transformCst.js +0 -25
  142. package/dist/transform/transformUtils.js +0 -7
  143. package/dist/utils.js +0 -30
  144. package/dist/visitAllNodes.js +0 -21
  145. /package/dist/{PrintFn.d.ts → src/PrintFn.d.ts} +0 -0
  146. /package/dist/{embed.d.ts → src/embed.d.ts} +0 -0
  147. /package/dist/{embedJs.d.ts → src/embedJs.d.ts} +0 -0
  148. /package/dist/{embedJson.d.ts → src/embedJson.d.ts} +0 -0
  149. /package/dist/{embedSql.d.ts → src/embedSql.d.ts} +0 -0
  150. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  151. /package/dist/{options.d.ts → src/options.d.ts} +0 -0
  152. /package/dist/{printComment.d.ts → src/printComment.d.ts} +0 -0
  153. /package/dist/{printSql.d.ts → src/printSql.d.ts} +0 -0
  154. /package/dist/{print_utils.d.ts → src/print_utils.d.ts} +0 -0
  155. /package/dist/{syntax → src/syntax}/alias.d.ts +0 -0
  156. /package/dist/{syntax → src/syntax}/alter_action.d.ts +0 -0
  157. /package/dist/{syntax → src/syntax}/alter_table.d.ts +0 -0
  158. /package/dist/{syntax → src/syntax}/analyze.d.ts +0 -0
  159. /package/dist/{syntax → src/syntax}/base.d.ts +0 -0
  160. /package/dist/{syntax → src/syntax}/cast.d.ts +0 -0
  161. /package/dist/{syntax → src/syntax}/comment.d.ts +0 -0
  162. /package/dist/{syntax → src/syntax}/create_table.d.ts +0 -0
  163. /package/dist/{syntax → src/syntax}/data_type.d.ts +0 -0
  164. /package/dist/{syntax → src/syntax}/dcl.d.ts +0 -0
  165. /package/dist/{syntax → src/syntax}/delete.d.ts +0 -0
  166. /package/dist/{syntax → src/syntax}/dialects/bigquery.d.ts +0 -0
  167. /package/dist/{syntax → src/syntax}/dialects/mysql.d.ts +0 -0
  168. /package/dist/{syntax → src/syntax}/dialects/postgresql.d.ts +0 -0
  169. /package/dist/{syntax → src/syntax}/dialects/sqlite.d.ts +0 -0
  170. /package/dist/{syntax → src/syntax}/do.d.ts +0 -0
  171. /package/dist/{syntax → src/syntax}/domain.d.ts +0 -0
  172. /package/dist/{syntax → src/syntax}/drop_table.d.ts +0 -0
  173. /package/dist/{syntax → src/syntax}/explain.d.ts +0 -0
  174. /package/dist/{syntax → src/syntax}/expr.d.ts +0 -0
  175. /package/dist/{syntax → src/syntax}/extension.d.ts +0 -0
  176. /package/dist/{syntax → src/syntax}/frame.d.ts +0 -0
  177. /package/dist/{syntax → src/syntax}/function.d.ts +0 -0
  178. /package/dist/{syntax → src/syntax}/index.d.ts +0 -0
  179. /package/dist/{syntax → src/syntax}/insert.d.ts +0 -0
  180. /package/dist/{syntax → src/syntax}/merge.d.ts +0 -0
  181. /package/dist/{syntax → src/syntax}/other_clauses.d.ts +0 -0
  182. /package/dist/{syntax → src/syntax}/parameter.d.ts +0 -0
  183. /package/dist/{syntax → src/syntax}/policy.d.ts +0 -0
  184. /package/dist/{syntax → src/syntax}/prepared_statements.d.ts +0 -0
  185. /package/dist/{syntax → src/syntax}/proc_clause.d.ts +0 -0
  186. /package/dist/{syntax → src/syntax}/procedural_language.d.ts +0 -0
  187. /package/dist/{syntax → src/syntax}/procedure.d.ts +0 -0
  188. /package/dist/{syntax → src/syntax}/program.d.ts +0 -0
  189. /package/dist/{syntax → src/syntax}/publication.d.ts +0 -0
  190. /package/dist/{syntax → src/syntax}/rename_table.d.ts +0 -0
  191. /package/dist/{syntax → src/syntax}/role.d.ts +0 -0
  192. /package/dist/{syntax → src/syntax}/schema.d.ts +0 -0
  193. /package/dist/{syntax → src/syntax}/select.d.ts +0 -0
  194. /package/dist/{syntax → src/syntax}/sequence.d.ts +0 -0
  195. /package/dist/{syntax → src/syntax}/subscription.d.ts +0 -0
  196. /package/dist/{syntax → src/syntax}/transaction.d.ts +0 -0
  197. /package/dist/{syntax → src/syntax}/transformMap.d.ts +0 -0
  198. /package/dist/{syntax → src/syntax}/trigger.d.ts +0 -0
  199. /package/dist/{syntax → src/syntax}/truncate.d.ts +0 -0
  200. /package/dist/{syntax → src/syntax}/type.d.ts +0 -0
  201. /package/dist/{syntax → src/syntax}/unsupported_grammar.d.ts +0 -0
  202. /package/dist/{syntax → src/syntax}/update.d.ts +0 -0
  203. /package/dist/{syntax → src/syntax}/view.d.ts +0 -0
  204. /package/dist/{transform → src/transform}/addFinalSemicolon.d.ts +0 -0
  205. /package/dist/{transform → src/transform}/aliasAs.d.ts +0 -0
  206. /package/dist/{transform → src/transform}/canonicKeywords.d.ts +0 -0
  207. /package/dist/{transform → src/transform}/canonicOperators.d.ts +0 -0
  208. /package/dist/{transform → src/transform}/comments.d.ts +0 -0
  209. /package/dist/{transform → src/transform}/stripTrailingCommas.d.ts +0 -0
  210. /package/dist/{transform → src/transform}/transformCst.d.ts +0 -0
  211. /package/dist/{transform → src/transform}/transformUtils.d.ts +0 -0
  212. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
  213. /package/dist/{visitAllNodes.d.ts → src/visitAllNodes.d.ts} +0 -0
package/dist/printSql.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printSql = void 0;
4
- var utils_1 = require("./utils");
5
- var transformMap_1 = require("./syntax/transformMap");
6
- var print_utils_1 = require("./print_utils");
7
- function printSql(path, options, oldPrint) {
8
- return printNode(path, options, createPrintFn(path, oldPrint, options));
9
- }
10
- exports.printSql = printSql;
11
- var cachedPrintFn;
12
- var cachedPath;
13
- function createPrintFn(path, oldPrint, opts) {
14
- // The path parameter will reference the same AstPath instance
15
- // during the whole printing cycle.
16
- // So we can keep using the same print function as long as
17
- // the path stays the same.
18
- if (cachedPath === path) {
19
- return cachedPrintFn;
20
- }
21
- cachedPath = path;
22
- cachedPrintFn = (function (selector) {
23
- if ((0, utils_1.isArray)(selector)) {
24
- var node_1 = path.node;
25
- return selector.filter(function (sel) { return (0, utils_1.isDefined)(node_1[sel]); }).map(oldPrint);
26
- }
27
- else {
28
- return oldPrint(selector);
29
- }
30
- });
31
- cachedPrintFn.separated = function (separator, selector) {
32
- var node = path.node;
33
- var docs = (0, utils_1.arrayWrap)(selector)
34
- .filter(function (sel) { return (0, utils_1.isDefined)(node[sel]); })
35
- .map(function (sel) { return [sel, oldPrint(sel)]; })
36
- // skip empty arrays
37
- .filter(function (_a) {
38
- var sel = _a[0], doc = _a[1];
39
- return !(0, utils_1.isEmptyArray)(doc);
40
- })
41
- // only join with spaces when input to print was Node[]
42
- .map(function (_a) {
43
- var sel = _a[0], doc = _a[1];
44
- return ((0, utils_1.isArray)(node[sel]) ? (0, print_utils_1.join)(" ", doc) : doc);
45
- });
46
- return docs.length > 0 ? [(0, print_utils_1.join)(separator, docs)] : [];
47
- };
48
- cachedPrintFn.spaced = function (selector) { return cachedPrintFn.separated(" ", selector); };
49
- cachedPrintFn.dynamicLine = function () {
50
- var node = path.node;
51
- return (0, print_utils_1.containsNewline)(node, opts) ? print_utils_1.hardline : print_utils_1.line;
52
- };
53
- return cachedPrintFn;
54
- }
55
- function printNode(path, options, print) {
56
- var node = path.node;
57
- if ((0, utils_1.isArray)(node)) {
58
- return path.map(print);
59
- }
60
- if ((0, utils_1.isString)(node)) {
61
- return node;
62
- }
63
- if (!(node === null || node === void 0 ? void 0 : node.type)) {
64
- throw new Error("No type field on node: ".concat(JSON.stringify(node)));
65
- }
66
- var fn = transformMap_1.transformMap[node.type];
67
- if (!fn) {
68
- throw new Error("Unexpected node type: ".concat(node.type));
69
- }
70
- return fn(print, node, path, options);
71
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
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
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.hasEmptyLineBetweenNodes = exports.containsNewline = exports.join = exports.stripTrailingHardline = exports.breakParent = exports.ifBreak = exports.lineSuffix = exports.group = exports.indent = exports.softline = exports.hardline = exports.line = void 0;
14
- var prettier_1 = require("prettier");
15
- var utils_1 = require("./utils");
16
- exports.line = (_a = prettier_1.doc.builders, _a.line), exports.hardline = _a.hardline, exports.softline = _a.softline, exports.indent = _a.indent, exports.group = _a.group, exports.lineSuffix = _a.lineSuffix, exports.ifBreak = _a.ifBreak, exports.breakParent = _a.breakParent;
17
- var origJoin = prettier_1.doc.builders.join;
18
- exports.stripTrailingHardline = prettier_1.doc.utils.stripTrailingHardline;
19
- /** Improved join() that also accepts a non-array docs parameter */
20
- var join = function (sep, docs) {
21
- return (0, utils_1.isArray)(docs) ? origJoin(sep, docs) : docs;
22
- };
23
- exports.join = join;
24
- /** True when the Node contains a newline in original source code */
25
- var containsNewline = function (node, opts) {
26
- if (!node.range) {
27
- throw new Error("containsNewline() expected a Node with range info");
28
- }
29
- return prettier_1.util.hasNewlineInRange(opts.originalText, node.range[0], node.range[1]);
30
- };
31
- exports.containsNewline = containsNewline;
32
- var hasEmptyLineBetweenNodes = function (node1, node2, opts) {
33
- var _a, _b;
34
- if (!node1.range || !node2.range) {
35
- throw new Error("emptyLineBetweenNodes() expects Nodes with range info");
36
- }
37
- var start = node1.range[1];
38
- var end = node2.range[0];
39
- var indexes = emptyLineIndexes(opts.originalText.slice(start, end)).map(function (i) { return start + i; });
40
- // when no empty lines between nodes, we can return early
41
- if (indexes.length === 0) {
42
- return false;
43
- }
44
- // otherwise we need to check whether the empty line happens to be
45
- // inside a comment or between comments
46
- var comments = __spreadArray(__spreadArray([], ((_a = node1.trailing) !== null && _a !== void 0 ? _a : []), true), ((_b = node2.leading) !== null && _b !== void 0 ? _b : []), true);
47
- return (indexes.filter(function (index) { return !isIndexInsideOrBetweenComments(index, comments); })
48
- .length > 0);
49
- };
50
- exports.hasEmptyLineBetweenNodes = hasEmptyLineBetweenNodes;
51
- function emptyLineIndexes(text) {
52
- var indexes = [];
53
- var re = /\n[ \t]*\r?\n/g;
54
- var match;
55
- while ((match = re.exec(text))) {
56
- indexes.push(match.index);
57
- }
58
- return indexes;
59
- }
60
- function isIndexInsideOrBetweenComments(index, comments) {
61
- if (comments.length === 0) {
62
- return false;
63
- }
64
- // Assume all nodes have range info
65
- var start = comments[0].range[0];
66
- var end = comments[comments.length - 1].range[1];
67
- return start <= index && index <= end;
68
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.aliasMap = void 0;
4
- exports.aliasMap = {
5
- alias: function (print) { return print.spaced(["expr", "asKw", "alias", "columnAliases"]); },
6
- };
@@ -1,213 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alterActionMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- var constraint_1 = require("./constraint");
6
- exports.alterActionMap = {
7
- alter_action_rename: function (print) { return print.spaced(["renameKw", "newName"]); },
8
- alter_action_rename_column: function (print) {
9
- return print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]);
10
- },
11
- alter_action_add_column: function (print) {
12
- return print.spaced(["addKw", "ifNotExistsKw", "column"]);
13
- },
14
- alter_action_drop_column: function (print) {
15
- return print.spaced(["dropKw", "ifExistsKw", "column", "behaviorKw"]);
16
- },
17
- alter_action_set_bigquery_options: function (print) {
18
- return print.spaced(["setKw", "options"]);
19
- },
20
- alter_action_set_default_collate: function (print) {
21
- return print.spaced(["setDefaultCollateKw", "collation"]);
22
- },
23
- /** cst-ignore: constraint, modifiers */
24
- alter_action_add_constraint: function (print, node) {
25
- return (0, print_utils_1.group)([
26
- print.spaced(["addKw", "name"]),
27
- (0, print_utils_1.indent)([print_utils_1.line, (0, constraint_1.printUnnamedConstraint)(print, node)]),
28
- ]);
29
- },
30
- alter_action_add_constraint_constraint_name: function (print) {
31
- return print.spaced(["constraintKw", "ifNotExistsKw", "name"]);
32
- },
33
- alter_action_drop_constraint: function (print) {
34
- return print.spaced([
35
- "dropConstraintKw",
36
- "ifExistsKw",
37
- "constraint",
38
- "behaviorKw",
39
- ]);
40
- },
41
- alter_action_drop_primary_key: function (print) {
42
- return print.spaced(["dropPrimaryKeyKw", "ifExistsKw"]);
43
- },
44
- alter_action_alter_constraint: function (print) {
45
- return print.spaced(["alterConstraintKw", "constraint", "modifiers"]);
46
- },
47
- alter_action_rename_constraint: function (print) {
48
- return print.spaced(["renameConstraintKw", "oldName", "toKw", "newName"]);
49
- },
50
- alter_action_validate_constraint: function (print) {
51
- return print.spaced(["validateConstraintKw", "constraint"]);
52
- },
53
- alter_action_set_visible: function (print) { return print.spaced("setVisibleKw"); },
54
- alter_action_set_invisible: function (print) { return print.spaced("setInvisibleKw"); },
55
- alter_action_set_tablespace: function (print) {
56
- return print.spaced(["setTablespaceKw", "tablespace", "nowaitKw"]);
57
- },
58
- alter_action_set_schema: function (print) { return print.spaced(["setSchemaKw", "schema"]); },
59
- alter_action_enable: function (print) { return print.spaced(["enableKw", "modeKw", "item"]); },
60
- alter_action_disable: function (print) { return print.spaced(["disableKw", "item"]); },
61
- alter_action_force: function (print) { return print.spaced(["forceKw", "item"]); },
62
- alter_action_no_force: function (print) { return print.spaced(["noForceKw", "item"]); },
63
- alter_action_cluster_on: function (print) { return print.spaced(["clusterOnKw", "index"]); },
64
- alter_action_set_without_cluster: function (print) {
65
- return print.spaced("setWithoutClusterKw");
66
- },
67
- alter_action_set_without_oids: function (print) { return print.spaced("setWithoutOidsKw"); },
68
- alter_action_set_access_method: function (print) {
69
- return print.spaced(["setAccessMethodKw", "method"]);
70
- },
71
- alter_action_set_logged: function (print) { return print.spaced("setLoggedKw"); },
72
- alter_action_set_unlogged: function (print) { return print.spaced("setUnloggedKw"); },
73
- alter_action_inherit: function (print) { return print.spaced(["inheritKw", "table"]); },
74
- alter_action_no_inherit: function (print) { return print.spaced(["noInheritKw", "table"]); },
75
- alter_action_of_type: function (print) { return print.spaced(["ofKw", "typeName"]); },
76
- alter_action_not_of_type: function (print) { return print.spaced("notOfKw"); },
77
- alter_action_owner_to: function (print) { return print.spaced(["ownerToKw", "owner"]); },
78
- alter_action_replica_identity: function (print) {
79
- return print.spaced(["replicaIdentityKw", "identity"]);
80
- },
81
- replica_identity_using_index: function (print) {
82
- return print.spaced(["usingIndexKw", "index"]);
83
- },
84
- alter_action_set_postgresql_options: function (print) {
85
- return print.spaced(["setKw", "options"]);
86
- },
87
- alter_action_reset_postgresql_options: function (print) {
88
- return print.spaced(["resetKw", "options"]);
89
- },
90
- alter_action_depends_on_extension: function (print) {
91
- return print.spaced(["dependsOnExtensionKw", "extension"]);
92
- },
93
- alter_action_no_depends_on_extension: function (print) {
94
- return print.spaced(["noDependsOnExtensionKw", "extension"]);
95
- },
96
- alter_action_attach_partition: function (print) {
97
- return print.spaced(["attachPartitionKw", "index"]);
98
- },
99
- alter_action_add_enum_value: function (print) {
100
- return print.spaced(["addValueKw", "ifNotExistsKw", "value", "position"]);
101
- },
102
- alter_action_add_enum_value_position: function (print) {
103
- return print.spaced(["positionKw", "value"]);
104
- },
105
- alter_action_rename_enum_value: function (print) {
106
- return print.spaced(["renameValueKw", "oldValue", "toKw", "newValue"]);
107
- },
108
- alter_action_add_attribute: function (print) {
109
- return print.spaced([
110
- "addAttributeKw",
111
- "name",
112
- "dataType",
113
- "constraint",
114
- "behaviorKw",
115
- ]);
116
- },
117
- alter_action_drop_attribute: function (print) {
118
- return print.spaced(["dropAttributeKw", "ifExistsKw", "name", "behaviorKw"]);
119
- },
120
- alter_action_alter_attribute: function (print) {
121
- return print.spaced([
122
- "alterAttributeKw",
123
- "name",
124
- "setDataTypeKw",
125
- "dataType",
126
- "constraint",
127
- "behaviorKw",
128
- ]);
129
- },
130
- alter_action_rename_attribute: function (print) {
131
- return print.spaced([
132
- "renameAttributeKw",
133
- "oldName",
134
- "toKw",
135
- "newName",
136
- "behaviorKw",
137
- ]);
138
- },
139
- // ALTER COLUMN
140
- alter_action_alter_column: function (print) {
141
- return (0, print_utils_1.group)([
142
- print.spaced(["alterKw", "ifExistsKw", "column"]),
143
- print.dynamicLine(),
144
- print("action"),
145
- ]);
146
- },
147
- alter_action_set_default: function (print) { return print.spaced(["setDefaultKw", "expr"]); },
148
- alter_action_drop_default: function (print) { return print.spaced("dropDefaultKw"); },
149
- alter_action_set_not_null: function (print) { return print.spaced("setNotNullKw"); },
150
- alter_action_drop_not_null: function (print) { return print.spaced("dropNotNullKw"); },
151
- alter_action_set_data_type: function (print) {
152
- return print.spaced(["setDataTypeKw", "dataType", "clauses"]);
153
- },
154
- alter_action_set_statistics: function (print) {
155
- return print.spaced(["setStatisticsKw", "value"]);
156
- },
157
- alter_action_set_compression: function (print) {
158
- return print.spaced(["setCompressionKw", "method"]);
159
- },
160
- alter_action_set_storage: function (print) { return print.spaced(["setStorageKw", "typeKw"]); },
161
- alter_action_drop_expression: function (print) {
162
- return print.spaced(["dropExpressionKw", "ifExistsKw"]);
163
- },
164
- alter_action_drop_identity: function (print) {
165
- return print.spaced(["dropIdentityKw", "ifExistsKw"]);
166
- },
167
- alter_action_add_identity: function (print) {
168
- return print.spaced([
169
- "addGeneratedKw",
170
- "whenKw",
171
- "asIdentityKw",
172
- "sequenceOptions",
173
- ]);
174
- },
175
- alter_action_alter_identity: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, print("actions"))); },
176
- alter_action_set_generated: function (print) {
177
- return print.spaced(["setGeneratedKw", "whenKw"]);
178
- },
179
- alter_action_restart: function (print) {
180
- return print.spaced(["restartKw", "withKw", "value"]);
181
- },
182
- alter_action_set_sequence_option: function (print) {
183
- return print.spaced(["setKw", "option"]);
184
- },
185
- alter_action_with_role_options: function (print, node) {
186
- return node.withKw
187
- ? (0, print_utils_1.group)([print("withKw"), (0, print_utils_1.indent)([print_utils_1.line, (0, print_utils_1.join)(print_utils_1.line, print("options"))])])
188
- : // This works in tandem with the logic inside alter_role_stmt
189
- (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, print("options")));
190
- },
191
- alter_action_set_postgresql_option: function (print) {
192
- return print.spaced(["setKw", "name", "operator", "value"]);
193
- },
194
- alter_action_set_postgresql_option_from_current: function (print) {
195
- return print.spaced(["setKw", "name", "fromCurrentKw"]);
196
- },
197
- alter_action_reset_postgresql_option: function (print) {
198
- return print.spaced(["resetKw", "name"]);
199
- },
200
- alter_action_add_user: function (print) { return (0, print_utils_1.group)(print.spaced(["addUserKw", "users"])); },
201
- alter_action_drop_user: function (print) {
202
- return (0, print_utils_1.group)(print.spaced(["dropUserKw", "users"]));
203
- },
204
- // ENABLE/DISABLE ..
205
- toggle_trigger: function (print) { return print.spaced(["triggerKw", "name"]); },
206
- toggle_rule: function (print) { return print.spaced(["ruleKw", "name"]); },
207
- toggle_row_level_security: function (print) { return print.spaced("rowLevelSecurityKw"); },
208
- // SET DATA TYPE ...
209
- set_data_type_collate_clause: function (print) {
210
- return print.spaced(["collateKw", "collation"]);
211
- },
212
- set_data_type_using_clause: function (print) { return print.spaced(["usingKw", "expr"]); },
213
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alterTableMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.alterTableMap = {
6
- alter_table_stmt: function (print) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["alterTableKw", "ifExistsKw", "table"]),
9
- print.dynamicLine(),
10
- print("actions"),
11
- ]);
12
- },
13
- alter_table_all_in_tablespace_stmt: function (print) {
14
- return (0, print_utils_1.group)([
15
- print.spaced([
16
- "alterTableKw",
17
- "allInTablespaceKw",
18
- "tablespace",
19
- "ownedBy",
20
- ]),
21
- print.dynamicLine(),
22
- print("action"),
23
- ]);
24
- },
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")])]);
27
- },
28
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.analyzeMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.analyzeMap = {
6
- analyze_stmt: function (print) {
7
- return (0, print_utils_1.group)(print.spaced(["analyzeKw", "tableKw", "tables"]));
8
- },
9
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.castMap = void 0;
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"])); },
7
- };
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commentMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.commentMap = {
6
- comment_stmt: function (print) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["commentKw", "onKw", "target", "isKw"]),
9
- (0, print_utils_1.indent)([print_utils_1.line, print("message")]),
10
- ]);
11
- },
12
- comment_target_aggregate: function (print) {
13
- return (0, print_utils_1.group)([print.spaced(["aggregateKw", "name"]), print(["params"])]);
14
- },
15
- comment_target_function: function (print) {
16
- return (0, print_utils_1.group)([print.spaced(["functionKw", "name"]), print(["params"])]);
17
- },
18
- comment_target_procedure: function (print) {
19
- return (0, print_utils_1.group)([print.spaced(["procedureKw", "name"]), print(["params"])]);
20
- },
21
- comment_target_routine: function (print) {
22
- return (0, print_utils_1.group)([print.spaced(["routineKw", "name"]), print(["params"])]);
23
- },
24
- comment_target_access_method: function (print) {
25
- return (0, print_utils_1.group)(print.spaced(["accessMethodKw", "name"]));
26
- },
27
- comment_target_cast: function (print) { return (0, print_utils_1.group)(print.spaced(["castKw", "args"])); },
28
- comment_target_collation: function (print) {
29
- return (0, print_utils_1.group)(print.spaced(["collationKw", "name"]));
30
- },
31
- comment_target_column: function (print) { return (0, print_utils_1.group)(print.spaced(["columnKw", "name"])); },
32
- comment_target_table_constraint: function (print) {
33
- return (0, print_utils_1.group)(print.spaced(["constraintKw", "name", "onKw", "tableName"]));
34
- },
35
- comment_target_domain_constraint: function (print) {
36
- return (0, print_utils_1.group)(print.spaced(["constraintKw", "name", "onKw", "domainKw", "domainName"]));
37
- },
38
- comment_target_conversion: function (print) {
39
- return (0, print_utils_1.group)(print.spaced(["conversionKw", "name"]));
40
- },
41
- comment_target_database: function (print) {
42
- return (0, print_utils_1.group)(print.spaced(["databaseKw", "name"]));
43
- },
44
- comment_target_domain: function (print) { return (0, print_utils_1.group)(print.spaced(["domainKw", "name"])); },
45
- comment_target_extension: function (print) {
46
- return (0, print_utils_1.group)(print.spaced(["extensionKw", "name"]));
47
- },
48
- comment_target_event_trigger: function (print) {
49
- return (0, print_utils_1.group)(print.spaced(["eventTriggerKw", "name"]));
50
- },
51
- comment_target_foreign_data_wrapper: function (print) {
52
- return (0, print_utils_1.group)(print.spaced(["foreignDataWrapperKw", "name"]));
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"])); },
123
- };
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
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 = {
15
- /** cst-ignore: constraint, modifiers */
16
- constraint: function (print, node) {
17
- if (node.name) {
18
- return (0, print_utils_1.group)([
19
- print("name"),
20
- (0, print_utils_1.indent)([print_utils_1.line, (0, exports.printUnnamedConstraint)(print, node)]),
21
- ]);
22
- }
23
- else {
24
- return (0, exports.printUnnamedConstraint)(print, node);
25
- }
26
- },
27
- constraint_name: function (print) { return print.spaced(["constraintKw", "name"]); },
28
- constraint_modifier: function (print) { return print.spaced("kw"); },
29
- constraint_null: function (print) { return print("nullKw"); },
30
- constraint_not_null: function (print) { return (0, print_utils_1.group)(print.spaced(["notNullKw", "clauses"])); },
31
- constraint_default: function (print) { return (0, print_utils_1.group)(print.spaced(["defaultKw", "expr"])); },
32
- constraint_primary_key: function (print) {
33
- return (0, print_utils_1.group)(print.spaced(["primaryKeyKw", "direction", "columns", "clauses"]));
34
- },
35
- constraint_unique: function (print) {
36
- return (0, print_utils_1.group)(print.spaced(["uniqueKw", "columns", "nullsKw", "clauses"]));
37
- },
38
- existing_index: function (print) { return print.spaced(["usingIndexKw", "index"]); },
39
- constraint_check: function (print) {
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"]);
50
- if (node.options.length > 0) {
51
- return (0, print_utils_1.group)([
52
- baseDoc,
53
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("options"))]),
54
- ]);
55
- }
56
- else {
57
- return baseDoc;
58
- }
59
- },
60
- referential_action: function (print) {
61
- return print.spaced(["onKw", "eventKw", "actionKw", "columns"]);
62
- },
63
- referential_match: function (print) { return print.spaced(["matchKw", "typeKw"]); },
64
- constraint_generated: function (print) {
65
- return print.spaced([
66
- "generatedKw",
67
- "asKw",
68
- "expr",
69
- "storageKw",
70
- "sequenceOptions",
71
- ]);
72
- },
73
- identity_column: function (print) { return print("identityKw"); },
74
- constraint_auto_increment: function (print) { return print("autoIncrementKw"); },
75
- on_conflict_clause: function (print) { return print.spaced(["onConflictKw", "resolutionKw"]); },
76
- constraint_comment: function (print) { return print.spaced(["commentKw", "value"]); },
77
- constraint_index: function (print) {
78
- return print.spaced(["indexTypeKw", "indexKw", "columns"]);
79
- },
80
- constraint_visible: function (print) { return print.spaced(["visibleKw"]); },
81
- constraint_column_format: function (print) {
82
- return print.spaced(["columnFormatKw", "formatKw"]);
83
- },
84
- constraint_storage: function (print) { return print.spaced(["storageKw", "typeKw"]); },
85
- constraint_engine_attribute: function (print, node) {
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)),
97
- ]),
98
- ]);
99
- },
100
- exclusion_param: function (print) { return print.spaced(["index", "withKw", "operator"]); },
101
- index_tablespace_clause: function (print) {
102
- return print.spaced(["usingIndexTablespaceKw", "name"]);
103
- },
104
- };
105
- var printUnnamedConstraint = function (print, node) {
106
- if (node.modifiers.length > 0) {
107
- return (0, print_utils_1.group)([
108
- print("constraint"),
109
- (0, print_utils_1.indent)([print_utils_1.line, print.spaced("modifiers")]),
110
- ]);
111
- }
112
- else {
113
- return print("constraint");
114
- }
115
- };
116
- exports.printUnnamedConstraint = printUnnamedConstraint;