pg-sql2 5.0.0-rc.3 → 5.0.0-rc.5

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $$type } from "./thereCanBeOnlyOne.js";
2
- export { version } from "./version.js";
1
+ import { $$type } from "./thereCanBeOnlyOne.ts";
2
+ export { version } from "./version.ts";
3
3
  /** Use this to enable coercing objects to SQL to make composing SQL fragments more ergonomic */
4
4
  export declare const $$toSQL: unique symbol;
5
5
  /** Experimental! */
package/dist/index.js CHANGED
@@ -24,9 +24,9 @@ const tslib_1 = require("tslib");
24
24
  const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
25
25
  const assert = tslib_1.__importStar(require("assert"));
26
26
  const util_1 = require("util");
27
- const thereCanBeOnlyOne_js_1 = require("./thereCanBeOnlyOne.js");
28
- var version_js_1 = require("./version.js");
29
- Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_js_1.version; } });
27
+ const thereCanBeOnlyOne_ts_1 = require("./thereCanBeOnlyOne.js");
28
+ var version_ts_1 = require("./version.js");
29
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_ts_1.version; } });
30
30
  /** Use this to enable coercing objects to SQL to make composing SQL fragments more ergonomic */
31
31
  exports.$$toSQL = Symbol("toSQL");
32
32
  function exportAs(thing, exportName) {
@@ -50,7 +50,7 @@ const isDev = typeof process !== "undefined" &&
50
50
  process.env.GRAPHILE_ENV === "test");
51
51
  const defaultIncludeComments = isDev || (typeof process !== "undefined" && process.env.PGSQL2_DEBUG === "1");
52
52
  const nodeInspect = function (depth, options) {
53
- if (this[thereCanBeOnlyOne_js_1.$$type] === "VALUE") {
53
+ if (this[thereCanBeOnlyOne_ts_1.$$type] === "VALUE") {
54
54
  if (depth < 0) {
55
55
  return `sql.value(...)`;
56
56
  }
@@ -59,22 +59,22 @@ const nodeInspect = function (depth, options) {
59
59
  depth: options.depth == null ? null : options.depth - 1,
60
60
  })})`;
61
61
  }
62
- else if (this[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
62
+ else if (this[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
63
63
  return `sql\`${this.t}\``;
64
64
  }
65
- else if (this[thereCanBeOnlyOne_js_1.$$type] === "IDENTIFIER") {
65
+ else if (this[thereCanBeOnlyOne_ts_1.$$type] === "IDENTIFIER") {
66
66
  return `sql.identifier(${JSON.stringify(this.n)})`;
67
67
  }
68
- else if (this[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
68
+ else if (this[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
69
69
  if (depth < 0) {
70
70
  return `sql\`...\``;
71
71
  }
72
72
  else {
73
- return `sql\`${this.n.map((n) => (n[thereCanBeOnlyOne_js_1.$$type] === "RAW" ? n.t : "${" + nodeInspect.call(n, depth + 1, options) + "}")).join("")}\``;
73
+ return `sql\`${this.n.map((n) => (n[thereCanBeOnlyOne_ts_1.$$type] === "RAW" ? n.t : "${" + nodeInspect.call(n, depth + 1, options) + "}")).join("")}\``;
74
74
  }
75
75
  }
76
76
  else {
77
- return `sql{${this[thereCanBeOnlyOne_js_1.$$type]}}`;
77
+ return `sql{${this[thereCanBeOnlyOne_ts_1.$$type]}}`;
78
78
  }
79
79
  };
80
80
  const pgSQL2Proto = Object.assign(Object.create(null), {
@@ -136,7 +136,7 @@ function makeRawNode(text, exportName) {
136
136
  }
137
137
  const newNode = {
138
138
  __proto__: pgSQL2Proto,
139
- [thereCanBeOnlyOne_js_1.$$type]: "RAW",
139
+ [thereCanBeOnlyOne_ts_1.$$type]: "RAW",
140
140
  t: text,
141
141
  };
142
142
  if (exportName) {
@@ -156,7 +156,7 @@ function makeCommentNode(rawCommentText) {
156
156
  .replace(/\/\*/g, "/ *");
157
157
  const newNode = {
158
158
  __proto__: pgSQL2Proto,
159
- [thereCanBeOnlyOne_js_1.$$type]: "COMMENT",
159
+ [thereCanBeOnlyOne_ts_1.$$type]: "COMMENT",
160
160
  commentText,
161
161
  };
162
162
  return newNode;
@@ -165,7 +165,7 @@ function makeCommentNode(rawCommentText) {
165
165
  function makeIdentifierNode(s, n = getSymbolName(s)) {
166
166
  return Object.freeze({
167
167
  __proto__: pgSQL2Proto,
168
- [thereCanBeOnlyOne_js_1.$$type]: "IDENTIFIER",
168
+ [thereCanBeOnlyOne_ts_1.$$type]: "IDENTIFIER",
169
169
  s,
170
170
  n,
171
171
  });
@@ -174,30 +174,30 @@ function makeIdentifierNode(s, n = getSymbolName(s)) {
174
174
  function makeValueNode(rawValue) {
175
175
  return Object.freeze({
176
176
  __proto__: pgSQL2Proto,
177
- [thereCanBeOnlyOne_js_1.$$type]: "VALUE",
177
+ [thereCanBeOnlyOne_ts_1.$$type]: "VALUE",
178
178
  v: rawValue,
179
179
  });
180
180
  }
181
181
  function makeIndentNode(content) {
182
- const flags = content[thereCanBeOnlyOne_js_1.$$type] === "QUERY" ? content.f : 0;
182
+ const flags = content[thereCanBeOnlyOne_ts_1.$$type] === "QUERY" ? content.f : 0;
183
183
  return Object.freeze({
184
- [thereCanBeOnlyOne_js_1.$$type]: "INDENT",
184
+ [thereCanBeOnlyOne_ts_1.$$type]: "INDENT",
185
185
  f: flags,
186
- c: content[thereCanBeOnlyOne_js_1.$$type] === "QUERY"
186
+ c: content[thereCanBeOnlyOne_ts_1.$$type] === "QUERY"
187
187
  ? content
188
188
  : makeQueryNode([enforceValidNode(content)]),
189
189
  });
190
190
  }
191
191
  function makeSymbolAliasNode(a, b) {
192
192
  return Object.freeze({
193
- [thereCanBeOnlyOne_js_1.$$type]: "SYMBOL_ALIAS",
193
+ [thereCanBeOnlyOne_ts_1.$$type]: "SYMBOL_ALIAS",
194
194
  a: a,
195
195
  b: b,
196
196
  });
197
197
  }
198
198
  function makePlaceholderNode(symbol, fallback) {
199
199
  return Object.freeze({
200
- [thereCanBeOnlyOne_js_1.$$type]: "PLACEHOLDER",
200
+ [thereCanBeOnlyOne_ts_1.$$type]: "PLACEHOLDER",
201
201
  s: symbol,
202
202
  k: fallback,
203
203
  });
@@ -205,7 +205,7 @@ function makePlaceholderNode(symbol, fallback) {
205
205
  function makeQueryNode(nodes, flags = 0) {
206
206
  let checksum = 0;
207
207
  for (const node of nodes) {
208
- switch (node[thereCanBeOnlyOne_js_1.$$type]) {
208
+ switch (node[thereCanBeOnlyOne_ts_1.$$type]) {
209
209
  case "RAW": {
210
210
  const { t } = node;
211
211
  // Max value of charCodeAt is 65535. 65535 * 10000 < 2^30.
@@ -238,14 +238,14 @@ function makeQueryNode(nodes, flags = 0) {
238
238
  break;
239
239
  }
240
240
  default: {
241
- const never = node[thereCanBeOnlyOne_js_1.$$type];
241
+ const never = node[thereCanBeOnlyOne_ts_1.$$type];
242
242
  throw new Error(`Unrecognized node type ${never}`);
243
243
  }
244
244
  }
245
245
  }
246
246
  return Object.freeze({
247
247
  __proto__: pgSQL2Proto,
248
- [thereCanBeOnlyOne_js_1.$$type]: "QUERY",
248
+ [thereCanBeOnlyOne_ts_1.$$type]: "QUERY",
249
249
  n: nodes,
250
250
  f: flags,
251
251
  c: checksum,
@@ -254,7 +254,7 @@ function makeQueryNode(nodes, flags = 0) {
254
254
  function isSQL(node) {
255
255
  return (typeof node === "object" &&
256
256
  node !== null &&
257
- typeof node[thereCanBeOnlyOne_js_1.$$type] === "string");
257
+ typeof node[thereCanBeOnlyOne_ts_1.$$type] === "string");
258
258
  }
259
259
  function isSQLable(value) {
260
260
  return (typeof value === "object" &&
@@ -333,19 +333,19 @@ function compile(sql, options) {
333
333
  * Join this to generate the SQL query
334
334
  */
335
335
  const sqlFragments = [];
336
- const trustedInput = untrustedInput?.[thereCanBeOnlyOne_js_1.$$type] !== undefined
336
+ const trustedInput = untrustedInput?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
337
337
  ? untrustedInput
338
338
  : enforceValidNode(untrustedInput, ``);
339
- const items = trustedInput[thereCanBeOnlyOne_js_1.$$type] === "QUERY"
339
+ const items = trustedInput[thereCanBeOnlyOne_ts_1.$$type] === "QUERY"
340
340
  ? expandQueryNodes(trustedInput)
341
341
  : [trustedInput];
342
342
  const itemCount = items.length;
343
343
  for (let itemIndex = 0; itemIndex < itemCount; itemIndex++) {
344
344
  const itemAtIndex = items[itemIndex];
345
- const item = itemAtIndex?.[thereCanBeOnlyOne_js_1.$$type] !== undefined
345
+ const item = itemAtIndex?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
346
346
  ? itemAtIndex
347
347
  : enforceValidNode(itemAtIndex, `item ${itemIndex}`);
348
- switch (item[thereCanBeOnlyOne_js_1.$$type]) {
348
+ switch (item[thereCanBeOnlyOne_ts_1.$$type]) {
349
349
  case "RAW": {
350
350
  if (item.t === "") {
351
351
  // No need to add blank raw text!
@@ -492,19 +492,19 @@ const sqlBase = function sql(strings, ...values) {
492
492
  currentText += text;
493
493
  if (i < l - 1) {
494
494
  const rawVal = values[i];
495
- const valid = rawVal?.[thereCanBeOnlyOne_js_1.$$type] !== undefined
495
+ const valid = rawVal?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
496
496
  ? rawVal
497
497
  : enforceValidNode(rawVal, `template literal placeholder ${i}`);
498
- if (valid[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
498
+ if (valid[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
499
499
  currentText += valid.t;
500
500
  }
501
- else if (valid[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
501
+ else if (valid[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
502
502
  // NOTE: this clears the flags
503
503
  const nodes = expandQueryNodes(valid);
504
504
  const nodeCount = nodes.length;
505
505
  for (let nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) {
506
506
  const node = nodes[nodeIndex];
507
- if (node[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
507
+ if (node[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
508
508
  currentText += node.t;
509
509
  }
510
510
  else {
@@ -671,7 +671,7 @@ function join(items, separator = "") {
671
671
  }
672
672
  else if (items.length === 1) {
673
673
  const rawNode = items[0];
674
- const node = rawNode?.[thereCanBeOnlyOne_js_1.$$type] !== undefined
674
+ const node = rawNode?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
675
675
  ? rawNode
676
676
  : enforceValidNode(rawNode, `join item ${0}`);
677
677
  return node;
@@ -682,15 +682,15 @@ function join(items, separator = "") {
682
682
  for (let i = 0, l = items.length; i < l; i++) {
683
683
  const rawNode = items[i];
684
684
  const addSeparator = i > 0 && hasSeparator;
685
- const node = rawNode?.[thereCanBeOnlyOne_js_1.$$type] !== undefined
685
+ const node = rawNode?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
686
686
  ? rawNode
687
687
  : enforceValidNode(rawNode, `join item ${i}`);
688
688
  if (addSeparator) {
689
689
  currentText += separator;
690
690
  }
691
- if (node[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
691
+ if (node[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
692
692
  for (const innerNode of expandQueryNodes(node)) {
693
- if (innerNode[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
693
+ if (innerNode[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
694
694
  currentText += innerNode.t;
695
695
  }
696
696
  else {
@@ -702,7 +702,7 @@ function join(items, separator = "") {
702
702
  }
703
703
  }
704
704
  }
705
- else if (node[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
705
+ else if (node[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
706
706
  currentText += node.t;
707
707
  }
708
708
  else {
@@ -753,7 +753,7 @@ function isIdentifierLike(p) {
753
753
  }
754
754
  function parenthesize(fragment, inFlags = 0) {
755
755
  const flags = inFlags | FLAG_HAS_PARENS;
756
- if (fragment[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
756
+ if (fragment[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
757
757
  return makeQueryNode(fragment.n, flags);
758
758
  }
759
759
  else {
@@ -785,7 +785,7 @@ function parenthesize(fragment, inFlags = 0) {
785
785
  * - An identifier `table.column.attribute` / `"MyTaBlE"."MyCoLuMn"."MyAtTrIbUtE"` (this needs to be `(table.column).attribute`)
786
786
  */
787
787
  function parens(frag, force) {
788
- if (frag[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
788
+ if (frag[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
789
789
  if ((frag.f & FLAG_HAS_PARENS) === FLAG_HAS_PARENS) {
790
790
  return frag;
791
791
  }
@@ -804,8 +804,8 @@ function parens(frag, force) {
804
804
  // Check for `IDENTIFIER.rawtext`
805
805
  // ENHANCE: check for 'rawtext.IDENTIFIER' too
806
806
  const [identifier, rawtext] = nodes;
807
- if (identifier[thereCanBeOnlyOne_js_1.$$type] !== "IDENTIFIER" ||
808
- rawtext[thereCanBeOnlyOne_js_1.$$type] !== "RAW" ||
807
+ if (identifier[thereCanBeOnlyOne_ts_1.$$type] !== "IDENTIFIER" ||
808
+ rawtext[thereCanBeOnlyOne_ts_1.$$type] !== "RAW" ||
809
809
  !rawtext.t.startsWith(".")) {
810
810
  return parenthesize(frag);
811
811
  }
@@ -820,13 +820,13 @@ function parens(frag, force) {
820
820
  for (let i = 0; i < nodeCount; i++) {
821
821
  const node = nodes[i];
822
822
  if (i % 2 === 0) {
823
- if (node[thereCanBeOnlyOne_js_1.$$type] !== "IDENTIFIER" &&
824
- (node[thereCanBeOnlyOne_js_1.$$type] !== "RAW" || !isIdentifierLike(node.t))) {
823
+ if (node[thereCanBeOnlyOne_ts_1.$$type] !== "IDENTIFIER" &&
824
+ (node[thereCanBeOnlyOne_ts_1.$$type] !== "RAW" || !isIdentifierLike(node.t))) {
825
825
  return parenthesize(frag);
826
826
  }
827
827
  }
828
828
  else {
829
- if (node[thereCanBeOnlyOne_js_1.$$type] !== "RAW" || node.t !== ".") {
829
+ if (node[thereCanBeOnlyOne_ts_1.$$type] !== "RAW" || node.t !== ".") {
830
830
  return parenthesize(frag);
831
831
  }
832
832
  }
@@ -837,9 +837,9 @@ function parens(frag, force) {
837
837
  return parenthesize(frag);
838
838
  }
839
839
  }
840
- else if (frag[thereCanBeOnlyOne_js_1.$$type] === "INDENT") {
840
+ else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "INDENT") {
841
841
  const inner = parens(frag.c, force);
842
- if (inner[thereCanBeOnlyOne_js_1.$$type] === "QUERY" &&
842
+ if (inner[thereCanBeOnlyOne_ts_1.$$type] === "QUERY" &&
843
843
  (inner.f & FLAG_HAS_PARENS) === FLAG_HAS_PARENS) {
844
844
  // Move the parens to outside
845
845
  return parenthesize(indent(makeQueryNode(inner.n)), inner.f);
@@ -854,16 +854,16 @@ function parens(frag, force) {
854
854
  else if (force) {
855
855
  return parenthesize(frag);
856
856
  }
857
- else if (frag[thereCanBeOnlyOne_js_1.$$type] === "VALUE") {
857
+ else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "VALUE") {
858
858
  return frag;
859
859
  }
860
- else if (frag[thereCanBeOnlyOne_js_1.$$type] === "IDENTIFIER") {
860
+ else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "IDENTIFIER") {
861
861
  return frag;
862
862
  }
863
- else if (frag[thereCanBeOnlyOne_js_1.$$type] === "COMMENT") {
863
+ else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "COMMENT") {
864
864
  return frag;
865
865
  }
866
- else if (frag[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
866
+ else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
867
867
  const expr = frag.t;
868
868
  if (expr.match(NUMBER_REGEX_1) || expr.match(NUMBER_REGEX_2)) {
869
869
  return frag;
@@ -924,31 +924,31 @@ function isEquivalent(sql1, sql2, options) {
924
924
  if (sql1 === sql2) {
925
925
  return true;
926
926
  }
927
- else if (sql1[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
928
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== "QUERY" || sql2.f !== sql1.f || sql2.c !== sql1.c) {
927
+ else if (sql1[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
928
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== "QUERY" || sql2.f !== sql1.f || sql2.c !== sql1.c) {
929
929
  return false;
930
930
  }
931
931
  return arraysMatch(sql1.n, sql2.n, (a, b) => isEquivalent(a, b, options));
932
932
  }
933
- else if (sql2[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
933
+ else if (sql2[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
934
934
  return false;
935
935
  }
936
936
  else {
937
- switch (sql1[thereCanBeOnlyOne_js_1.$$type]) {
937
+ switch (sql1[thereCanBeOnlyOne_ts_1.$$type]) {
938
938
  case "RAW": {
939
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
939
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== sql1[thereCanBeOnlyOne_ts_1.$$type]) {
940
940
  return false;
941
941
  }
942
942
  return sql1.t === sql2.t;
943
943
  }
944
944
  case "VALUE": {
945
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
945
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== sql1[thereCanBeOnlyOne_ts_1.$$type]) {
946
946
  return false;
947
947
  }
948
948
  return sql1.v === sql2.v;
949
949
  }
950
950
  case "INDENT": {
951
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
951
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== sql1[thereCanBeOnlyOne_ts_1.$$type]) {
952
952
  return false;
953
953
  }
954
954
  return isEquivalent(sql1.c, sql2.c, options);
@@ -957,7 +957,7 @@ function isEquivalent(sql1, sql2, options) {
957
957
  return true;
958
958
  }
959
959
  case "IDENTIFIER": {
960
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
960
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== sql1[thereCanBeOnlyOne_ts_1.$$type]) {
961
961
  return false;
962
962
  }
963
963
  const { n: ids1n, s: ids1s } = sql1;
@@ -970,7 +970,7 @@ function isEquivalent(sql1, sql2, options) {
970
970
  return namesMatch && symbolsMatch;
971
971
  }
972
972
  case "PLACEHOLDER": {
973
- if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
973
+ if (sql2[thereCanBeOnlyOne_ts_1.$$type] !== sql1[thereCanBeOnlyOne_ts_1.$$type]) {
974
974
  return false;
975
975
  }
976
976
  const symbolSubstitutes = options?.symbolSubstitutes;
@@ -991,7 +991,7 @@ function isEquivalent(sql1, sql2, options) {
991
991
  }
992
992
  }
993
993
  function replaceSymbolInNode(frag, needle, replacement) {
994
- switch (frag[thereCanBeOnlyOne_js_1.$$type]) {
994
+ switch (frag[thereCanBeOnlyOne_ts_1.$$type]) {
995
995
  case "COMMENT":
996
996
  case "RAW": {
997
997
  return frag;
@@ -1033,7 +1033,7 @@ function replaceSymbolInNode(frag, needle, replacement) {
1033
1033
  }
1034
1034
  default: {
1035
1035
  const never = frag;
1036
- throw new Error(`Unhandled SQL type ${never[thereCanBeOnlyOne_js_1.$$type]}`);
1036
+ throw new Error(`Unhandled SQL type ${never[thereCanBeOnlyOne_ts_1.$$type]}`);
1037
1037
  }
1038
1038
  }
1039
1039
  }
@@ -1041,7 +1041,7 @@ function replaceSymbolInNode(frag, needle, replacement) {
1041
1041
  * @experimental
1042
1042
  */
1043
1043
  function replaceSymbol(frag, needle, replacement) {
1044
- if (frag[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
1044
+ if (frag[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
1045
1045
  let changed = false;
1046
1046
  const newNodes = frag.n.map((node) => {
1047
1047
  const newNode = replaceSymbolInNode(node, needle, replacement);
@@ -1094,7 +1094,7 @@ function withTransformer(transformer, callback) {
1094
1094
  }
1095
1095
  /** If node is an identifier, return its symbol, otherwise return null */
1096
1096
  function getIdentifierSymbol(potentialIdentifier) {
1097
- if (potentialIdentifier[thereCanBeOnlyOne_js_1.$$type] === "IDENTIFIER") {
1097
+ if (potentialIdentifier[thereCanBeOnlyOne_ts_1.$$type] === "IDENTIFIER") {
1098
1098
  return potentialIdentifier.s;
1099
1099
  }
1100
1100
  else {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "5.0.0-rc.3";
1
+ export declare const version = "5.0.0-rc.5";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is autogenerated by /scripts/postversion.mjs
5
- exports.version = "5.0.0-rc.3";
5
+ exports.version = "5.0.0-rc.5";
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,16 +1,9 @@
1
1
  {
2
2
  "name": "pg-sql2",
3
- "version": "5.0.0-rc.3",
3
+ "version": "5.0.0-rc.5",
4
4
  "description": "Generate safe Postgres-compliant SQL with tagged template literals",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "scripts": {
8
- "pretest": "node dist/index.js",
9
- "test": "jest",
10
- "posttest": "yarn test:docs",
11
- "test:docs": "markdown-doctest",
12
- "prepack": "tsc -b"
13
- },
14
7
  "repository": {
15
8
  "type": "git",
16
9
  "url": "git+https://github.com/graphile/crystal.git"
@@ -34,17 +27,8 @@
34
27
  "url": "https://github.com/graphile/crystal/issues"
35
28
  },
36
29
  "homepage": "https://github.com/graphile/crystal/tree/main/utils/pg-sql2",
37
- "devDependencies": {
38
- "@types/debug": "^4.1.12",
39
- "@types/jest": "^30.0.0",
40
- "@types/node": "^22.19.1",
41
- "jest": "^30.2.0",
42
- "markdown-doctest": "^1.1.0",
43
- "ts-node": "^10.9.2",
44
- "typescript": "^5.9.3"
45
- },
46
30
  "dependencies": {
47
- "@graphile/lru": "^5.0.0-rc.3",
31
+ "@graphile/lru": "^5.0.0-rc.5",
48
32
  "tslib": "^2.8.1"
49
33
  },
50
34
  "files": [
package/CHANGELOG.md DELETED
@@ -1,296 +0,0 @@
1
- # pg-sql2
2
-
3
- ## 5.0.0-rc.3
4
-
5
- ### Patch Changes
6
-
7
- - [#2873](https://github.com/graphile/crystal/pull/2873)
8
- [`0772086`](https://github.com/graphile/crystal/commit/0772086411a55d56b4e345cff1eef133eee31b36)
9
- Thanks [@benjie](https://github.com/benjie)! - Update TypeScript configuration
10
- to support Node 22 minimum
11
-
12
- - [#2888](https://github.com/graphile/crystal/pull/2888)
13
- [`1a56db2`](https://github.com/graphile/crystal/commit/1a56db2f53bc455a3d3ba6555a2cd777b27b271c)
14
- Thanks [@benjaie](https://github.com/benjaie)! - Node v22+ is required for
15
- this module.
16
-
17
- - [#2869](https://github.com/graphile/crystal/pull/2869)
18
- [`afe31f0`](https://github.com/graphile/crystal/commit/afe31f09a5b204f79321f8db9b42440df23a1183)
19
- Thanks [@benjie](https://github.com/benjie)! - Don't allow recursion when
20
- calling `node[$$toSQL]()`; customize error message if `$$toSQL` was invoked.
21
-
22
- - [#2866](https://github.com/graphile/crystal/pull/2866)
23
- [`d3a1be9`](https://github.com/graphile/crystal/commit/d3a1be921d70d143a94ca376d9d08dd85269f5bf)
24
- Thanks [@benjie](https://github.com/benjie)! - More explicit types of exported
25
- PgSQL
26
-
27
- - Updated dependencies
28
- [[`0772086`](https://github.com/graphile/crystal/commit/0772086411a55d56b4e345cff1eef133eee31b36),
29
- [`1a56db2`](https://github.com/graphile/crystal/commit/1a56db2f53bc455a3d3ba6555a2cd777b27b271c)]:
30
- - @graphile/lru@5.0.0-rc.3
31
-
32
- ## 5.0.0-rc.2
33
-
34
- ### Patch Changes
35
-
36
- - [#2821](https://github.com/graphile/crystal/pull/2821)
37
- [`8cfe23f`](https://github.com/graphile/crystal/commit/8cfe23f6e694503ffb99a642f816e858275f5b4e)
38
- Thanks [@benjie](https://github.com/benjie)! - Add sql.json API
39
-
40
- - [#2829](https://github.com/graphile/crystal/pull/2829)
41
- [`a82e6fa`](https://github.com/graphile/crystal/commit/a82e6fae099f7e9d62fb3fc1ee173368cdabca27)
42
- Thanks [@benjie](https://github.com/benjie)! - Update dependency ranges.
43
-
44
- - Updated dependencies
45
- [[`a82e6fa`](https://github.com/graphile/crystal/commit/a82e6fae099f7e9d62fb3fc1ee173368cdabca27)]:
46
- - @graphile/lru@5.0.0-rc.2
47
-
48
- ## 5.0.0-rc.1
49
-
50
- ### Patch Changes
51
-
52
- - [#2740](https://github.com/graphile/crystal/pull/2740)
53
- [`31b388c`](https://github.com/graphile/crystal/commit/31b388c6d5546640af7dcf4e6021643e47892ed1)
54
- Thanks [@benjie](https://github.com/benjie)! - Support more comment strings.
55
-
56
- - [#2746](https://github.com/graphile/crystal/pull/2746)
57
- [`930240a`](https://github.com/graphile/crystal/commit/930240a4a7d3373f5691d495df752bb8fedac2af)
58
- Thanks [@jemgillam](https://github.com/jemgillam)! - New:
59
- `sql.comment("...", true)` forces comments to be included, even in production.
60
-
61
- - [`8a5a7c5`](https://github.com/graphile/crystal/commit/8a5a7c536fc4b9b702600c5cc3d413724670c327)
62
- Thanks [@benjie](https://github.com/benjie)! - Bump to release candidate
63
-
64
- - Updated dependencies
65
- [[`8a5a7c5`](https://github.com/graphile/crystal/commit/8a5a7c536fc4b9b702600c5cc3d413724670c327)]:
66
- - @graphile/lru@5.0.0-rc.1
67
-
68
- ## 5.0.0-beta.9
69
-
70
- ### Patch Changes
71
-
72
- - [#2434](https://github.com/graphile/crystal/pull/2434)
73
- [`5a26196eff8fd1956d73e0b8fdf5cfcb7f01b7d3`](https://github.com/graphile/crystal/commit/5a26196eff8fd1956d73e0b8fdf5cfcb7f01b7d3)
74
- Thanks [@benjie](https://github.com/benjie)! - `util.inspect(someSql)` will
75
- now output a much nicer string
76
-
77
- - [#2482](https://github.com/graphile/crystal/pull/2482)
78
- [`459e1869a2ec58925b2bac5458af487c52a8ca37`](https://github.com/graphile/crystal/commit/459e1869a2ec58925b2bac5458af487c52a8ca37)
79
- Thanks [@benjie](https://github.com/benjie)! - Minimum version of Node.js
80
- bumped to Node 22 (the latest LTS).
81
-
82
- - [#2450](https://github.com/graphile/crystal/pull/2450)
83
- [`a87bbd76f1a8b60fd86de65922746d830cc160b4`](https://github.com/graphile/crystal/commit/a87bbd76f1a8b60fd86de65922746d830cc160b4)
84
- Thanks [@benjie](https://github.com/benjie)! - Type-only tweak
85
-
86
- - [#2525](https://github.com/graphile/crystal/pull/2525)
87
- [`c9cd0cc72a4db4b02b2bdf770161c9346cb4b174`](https://github.com/graphile/crystal/commit/c9cd0cc72a4db4b02b2bdf770161c9346cb4b174)
88
- Thanks [@benjie](https://github.com/benjie)! - `sql.getIdentifierSymbol(node)`
89
- method added to extract a symbol from an identifier node (if a node is an
90
- identifier node, otherwise return `null`).
91
- - Updated dependencies
92
- [[`459e1869a2ec58925b2bac5458af487c52a8ca37`](https://github.com/graphile/crystal/commit/459e1869a2ec58925b2bac5458af487c52a8ca37)]:
93
- - @graphile/lru@5.0.0-beta.4
94
-
95
- ## 5.0.0-beta.8
96
-
97
- ### Patch Changes
98
-
99
- - [#2329](https://github.com/graphile/crystal/pull/2329)
100
- [`e10c372dafbe0d6014b1e946349b22f40aa87ef9`](https://github.com/graphile/crystal/commit/e10c372dafbe0d6014b1e946349b22f40aa87ef9)
101
- Thanks [@benjie](https://github.com/benjie)! - Fix bug causing unhelpful throw
102
- on $type optimization on null - instead pass through to more helpful throw.
103
-
104
- - [#2341](https://github.com/graphile/crystal/pull/2341)
105
- [`3b0f5082b2272997ce33ce8823a4752513d19e28`](https://github.com/graphile/crystal/commit/3b0f5082b2272997ce33ce8823a4752513d19e28)
106
- Thanks [@benjie](https://github.com/benjie)! - Some of the pg-sql2 inputs are
107
- now marked Readonly to indicate we won't mutate them.
108
-
109
- - [#2320](https://github.com/graphile/crystal/pull/2320)
110
- [`3789326b2e2fdb86519acc75e606c752ddefe590`](https://github.com/graphile/crystal/commit/3789326b2e2fdb86519acc75e606c752ddefe590)
111
- Thanks [@benjie](https://github.com/benjie)! - Add new `withTransformer`
112
- functionality to enable embedding of non-SQL values into PgSQL fragments, for
113
- improved user ergonomics.
114
-
115
- - [#2384](https://github.com/graphile/crystal/pull/2384)
116
- [`412b92a0b1e03ad962521f630b57a996d8620cf6`](https://github.com/graphile/crystal/commit/412b92a0b1e03ad962521f630b57a996d8620cf6)
117
- Thanks [@benjie](https://github.com/benjie)! - Small optimization/fix to
118
- `arraysMatch` function.
119
-
120
- ## 5.0.0-beta.7
121
-
122
- ### Patch Changes
123
-
124
- - [#2250](https://github.com/graphile/crystal/pull/2250)
125
- [`7bf045282`](https://github.com/graphile/crystal/commit/7bf04528264c3b9c509f148253fed96d3394141d)
126
- Thanks [@benjie](https://github.com/benjie)! - Export version number.
127
-
128
- ## 5.0.0-beta.6
129
-
130
- ### Patch Changes
131
-
132
- - [#1994](https://github.com/graphile/crystal/pull/1994)
133
- [`ab08cbf9c`](https://github.com/graphile/crystal/commit/ab08cbf9c504c3cc22495a99a965e7634c18a6a3)
134
- Thanks [@benjie](https://github.com/benjie)! - Introduce
135
- `interface SQLable {[$toSQL](): SQL}` to `pg-sql2` and use it to simplify SQL
136
- fragments in various places.
137
-
138
- - [#1973](https://github.com/graphile/crystal/pull/1973)
139
- [`94a05064e`](https://github.com/graphile/crystal/commit/94a05064ea05108685ff71174a9f871ab5b4c147)
140
- Thanks [@benjie](https://github.com/benjie)! - Fix processing of GRAPHILE_ENV
141
- to allow "test"
142
-
143
- ## 5.0.0-beta.5
144
-
145
- ### Patch Changes
146
-
147
- - [#1924](https://github.com/graphile/crystal/pull/1924)
148
- [`ef44c29b2`](https://github.com/graphile/crystal/commit/ef44c29b24a1ad5a042ae1536a4546dd64b17195)
149
- Thanks [@benjie](https://github.com/benjie)! - 🚨 TypeScript is now configured
150
- to hide interfaces marked as `@internal`. This may result in a few errors
151
- where you're accessing things you oughtn't be, but also may hide some
152
- interfaces that should be exposed - please file an issue if an API you were
153
- dependent on has been removed from the TypeScript typings. If that API happens
154
- to be `step.dependencies`; you should first read this:
155
- https://benjie.dev/graphql/ancestors
156
-
157
- ## 5.0.0-beta.4
158
-
159
- ### Patch Changes
160
-
161
- - [`2805edc68`](https://github.com/graphile/crystal/commit/2805edc68b90546bf71ffd293af4d87a79345825)
162
- Thanks [@benjie](https://github.com/benjie)! - Don't freeze object, so that it
163
- can be annotated as exportable.
164
-
165
- ## 5.0.0-beta.3
166
-
167
- ### Patch Changes
168
-
169
- - [#514](https://github.com/graphile/crystal-pre-merge/pull/514)
170
- [`c9848f693`](https://github.com/graphile/crystal-pre-merge/commit/c9848f6936a5abd7740c0638bfb458fb5551f03b)
171
- Thanks [@benjie](https://github.com/benjie)! - Update package.json repository
172
- information
173
-
174
- - Updated dependencies
175
- [[`c9848f693`](https://github.com/graphile/crystal-pre-merge/commit/c9848f6936a5abd7740c0638bfb458fb5551f03b)]:
176
- - @graphile/lru@5.0.0-beta.3
177
-
178
- ## 5.0.0-beta.2
179
-
180
- ### Patch Changes
181
-
182
- - [#496](https://github.com/benjie/crystal/pull/496)
183
- [`c9bfd9892`](https://github.com/benjie/crystal/commit/c9bfd989247f9433fb5b18c5175c9d8d64cd21a1)
184
- Thanks [@benjie](https://github.com/benjie)! - Update dependencies (sometimes
185
- through major versions).
186
-
187
- - Updated dependencies
188
- [[`c9bfd9892`](https://github.com/benjie/crystal/commit/c9bfd989247f9433fb5b18c5175c9d8d64cd21a1)]:
189
- - @graphile/lru@5.0.0-beta.2
190
-
191
- ## 5.0.0-beta.1
192
-
193
- ### Patch Changes
194
-
195
- - [`cbd987385`](https://github.com/benjie/crystal/commit/cbd987385f99bd1248bc093ac507cc2f641ba3e8)
196
- Thanks [@benjie](https://github.com/benjie)! - Bump all packages to beta
197
-
198
- - Updated dependencies
199
- [[`cbd987385`](https://github.com/benjie/crystal/commit/cbd987385f99bd1248bc093ac507cc2f641ba3e8)]:
200
- - @graphile/lru@5.0.0-beta.1
201
-
202
- ## 5.0.0-alpha.3
203
-
204
- ### Patch Changes
205
-
206
- - [#370](https://github.com/benjie/crystal/pull/370)
207
- [`339fe20d0`](https://github.com/benjie/crystal/commit/339fe20d0c6e8600d263ce8093cd85a6ea8adbbf)
208
- Thanks [@benjie](https://github.com/benjie)! - Allow multiple instances of
209
- pg-sql2 and tamedevil to help handle package manager shenanigans.
210
-
211
- ## 5.0.0-alpha.2
212
-
213
- ### Patch Changes
214
-
215
- - [`82cc01152`](https://github.com/benjie/crystal/commit/82cc01152ee06dafce45299661afd77ad943d785)
216
- Thanks [@benjie](https://github.com/benjie)! - Performance overhaul and new
217
- cache method.
218
-
219
- - [`7f857950a`](https://github.com/benjie/crystal/commit/7f857950a7e4ec763c936eb6bd1fb77824041d71)
220
- Thanks [@benjie](https://github.com/benjie)! - Upgrade to the latest
221
- TypeScript/tslib
222
-
223
- - Updated dependencies
224
- [[`98ae00f59`](https://github.com/benjie/crystal/commit/98ae00f59a8ab3edc5718ad8437a0dab734a7d69),
225
- [`7f857950a`](https://github.com/benjie/crystal/commit/7f857950a7e4ec763c936eb6bd1fb77824041d71)]:
226
- - @graphile/lru@5.0.0-alpha.2
227
-
228
- ## 5.0.0-alpha.1
229
-
230
- ### Patch Changes
231
-
232
- - [`759ad403d`](https://github.com/benjie/crystal/commit/759ad403d71363312c5225c165873ae84b8a098c)
233
- Thanks [@benjie](https://github.com/benjie)! - Alpha release - see
234
- https://postgraphile.org/news/2023-04-26-version-5-alpha
235
-
236
- - Updated dependencies
237
- [[`759ad403d`](https://github.com/benjie/crystal/commit/759ad403d71363312c5225c165873ae84b8a098c)]:
238
- - @graphile/lru@5.0.0-alpha.1
239
-
240
- ## 5.0.0-1.1
241
-
242
- ### Patch Changes
243
-
244
- - [#260](https://github.com/benjie/crystal/pull/260)
245
- [`d5312e6b9`](https://github.com/benjie/crystal/commit/d5312e6b968fbeb46d074b82a41b4bdbc166598c)
246
- Thanks [@benjie](https://github.com/benjie)! - TypeScript v5 is now required
247
-
248
- - [#270](https://github.com/benjie/crystal/pull/270)
249
- [`f93c79b94`](https://github.com/benjie/crystal/commit/f93c79b94eb93ae04b1b2e0478f5106e1aca8ee2)
250
- Thanks [@benjie](https://github.com/benjie)! - Experimental: expose
251
- `symbolToIdentifier` on `sql.compile()` result (via special
252
- `$symbolToIdentifier` symbol key) so you can determine which identifiers were
253
- used for which symbols.
254
-
255
- - [#270](https://github.com/benjie/crystal/pull/270)
256
- [`53e164cbc`](https://github.com/benjie/crystal/commit/53e164cbca7eaf1e6e03c849ac1bbe1789c61105)
257
- Thanks [@benjie](https://github.com/benjie)! - When the same `sql.value()`
258
- node is used in multiple places, it will now be replaced with the same
259
- placeholder (`$1`, etc).
260
- - Updated dependencies
261
- [[`d5312e6b9`](https://github.com/benjie/crystal/commit/d5312e6b968fbeb46d074b82a41b4bdbc166598c)]:
262
- - @graphile/lru@5.0.0-1.1
263
-
264
- ## 5.0.0-0.4
265
-
266
- ### Patch Changes
267
-
268
- - [#257](https://github.com/benjie/crystal/pull/257)
269
- [`8f323bdc8`](https://github.com/benjie/crystal/commit/8f323bdc88e39924de50775891bd40f1acb9b7cf)
270
- Thanks [@benjie](https://github.com/benjie)! - When multiple versions of
271
- grafast or pg-sql2 are detected, a warning will be raised.
272
-
273
- ## 5.0.0-0.3
274
-
275
- ### Patch Changes
276
-
277
- - [`0ab95d0b1`](undefined) - Update sponsors.
278
-
279
- ## 5.0.0-0.2
280
-
281
- ### Patch Changes
282
-
283
- - [`9b296ba54`](undefined) - More secure, more compatible, and lots of fixes
284
- across the monorepo
285
-
286
- ## 5.0.0-0.1
287
-
288
- ### Patch Changes
289
-
290
- - [#125](https://github.com/benjie/crystal/pull/125)
291
- [`91f2256b3`](https://github.com/benjie/crystal/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)
292
- Thanks [@benjie](https://github.com/benjie)! - Initial changesets release
293
-
294
- - Updated dependencies
295
- [[`91f2256b3`](https://github.com/benjie/crystal/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)]:
296
- - @graphile/lru@5.0.0-0.1