pg-sql2 5.0.0-rc.3 → 5.0.0-rc.4
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +61 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# pg-sql2
|
|
2
2
|
|
|
3
|
+
## 5.0.0-rc.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a3722d6`](https://github.com/graphile/crystal/commit/a3722d613bc6fb9e32f167aae9a31eaa422ceef1)
|
|
8
|
+
Thanks [@benjie](https://github.com/benjie)! - Refactor to enable TypeScript
|
|
9
|
+
options rewriteRelativeImportExtensions and erasableSyntaxOnly (including
|
|
10
|
+
using .ts extensions in source code)
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
[[`a3722d6`](https://github.com/graphile/crystal/commit/a3722d613bc6fb9e32f167aae9a31eaa422ceef1)]:
|
|
13
|
+
- @graphile/lru@5.0.0-rc.4
|
|
14
|
+
|
|
3
15
|
## 5.0.0-rc.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $$type } from "./thereCanBeOnlyOne.
|
|
2
|
-
export { version } from "./version.
|
|
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
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return
|
|
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[
|
|
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[
|
|
62
|
+
else if (this[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
63
63
|
return `sql\`${this.t}\``;
|
|
64
64
|
}
|
|
65
|
-
else if (this[
|
|
65
|
+
else if (this[thereCanBeOnlyOne_ts_1.$$type] === "IDENTIFIER") {
|
|
66
66
|
return `sql.identifier(${JSON.stringify(this.n)})`;
|
|
67
67
|
}
|
|
68
|
-
else if (this[
|
|
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[
|
|
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[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
177
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "VALUE",
|
|
178
178
|
v: rawValue,
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
function makeIndentNode(content) {
|
|
182
|
-
const flags = content[
|
|
182
|
+
const flags = content[thereCanBeOnlyOne_ts_1.$$type] === "QUERY" ? content.f : 0;
|
|
183
183
|
return Object.freeze({
|
|
184
|
-
[
|
|
184
|
+
[thereCanBeOnlyOne_ts_1.$$type]: "INDENT",
|
|
185
185
|
f: flags,
|
|
186
|
-
c: content[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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[
|
|
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[
|
|
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
|
-
[
|
|
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[
|
|
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?.[
|
|
336
|
+
const trustedInput = untrustedInput?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
337
337
|
? untrustedInput
|
|
338
338
|
: enforceValidNode(untrustedInput, ``);
|
|
339
|
-
const items = trustedInput[
|
|
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?.[
|
|
345
|
+
const item = itemAtIndex?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
346
346
|
? itemAtIndex
|
|
347
347
|
: enforceValidNode(itemAtIndex, `item ${itemIndex}`);
|
|
348
|
-
switch (item[
|
|
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?.[
|
|
495
|
+
const valid = rawVal?.[thereCanBeOnlyOne_ts_1.$$type] !== undefined
|
|
496
496
|
? rawVal
|
|
497
497
|
: enforceValidNode(rawVal, `template literal placeholder ${i}`);
|
|
498
|
-
if (valid[
|
|
498
|
+
if (valid[thereCanBeOnlyOne_ts_1.$$type] === "RAW") {
|
|
499
499
|
currentText += valid.t;
|
|
500
500
|
}
|
|
501
|
-
else if (valid[
|
|
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[
|
|
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?.[
|
|
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?.[
|
|
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[
|
|
691
|
+
if (node[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
|
|
692
692
|
for (const innerNode of expandQueryNodes(node)) {
|
|
693
|
-
if (innerNode[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
808
|
-
rawtext[
|
|
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[
|
|
824
|
-
(node[
|
|
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[
|
|
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[
|
|
840
|
+
else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "INDENT") {
|
|
841
841
|
const inner = parens(frag.c, force);
|
|
842
|
-
if (inner[
|
|
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[
|
|
857
|
+
else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "VALUE") {
|
|
858
858
|
return frag;
|
|
859
859
|
}
|
|
860
|
-
else if (frag[
|
|
860
|
+
else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "IDENTIFIER") {
|
|
861
861
|
return frag;
|
|
862
862
|
}
|
|
863
|
-
else if (frag[
|
|
863
|
+
else if (frag[thereCanBeOnlyOne_ts_1.$$type] === "COMMENT") {
|
|
864
864
|
return frag;
|
|
865
865
|
}
|
|
866
|
-
else if (frag[
|
|
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[
|
|
928
|
-
if (sql2[
|
|
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[
|
|
933
|
+
else if (sql2[thereCanBeOnlyOne_ts_1.$$type] === "QUERY") {
|
|
934
934
|
return false;
|
|
935
935
|
}
|
|
936
936
|
else {
|
|
937
|
-
switch (sql1[
|
|
937
|
+
switch (sql1[thereCanBeOnlyOne_ts_1.$$type]) {
|
|
938
938
|
case "RAW": {
|
|
939
|
-
if (sql2[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
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[
|
|
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.
|
|
1
|
+
export declare const version = "5.0.0-rc.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-sql2",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.4",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@graphile/lru": "^5.0.0-rc.
|
|
47
|
+
"@graphile/lru": "^5.0.0-rc.4",
|
|
48
48
|
"tslib": "^2.8.1"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|