drizzle-cube 0.1.67 → 0.1.69
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/adapters/{compiler-BEgt1OH1.js → compiler-BnHK-nxh.js} +1231 -1003
- package/dist/adapters/compiler-CghsDLXl.cjs +22 -0
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/utils.d.ts +2 -1
- package/dist/client/chunks/{components-Bbd9Us6e.js → components-DALzorPs.js} +9507 -8735
- package/dist/client/chunks/components-DALzorPs.js.map +1 -0
- package/dist/client/chunks/{icons-a6fQwcor.js → icons-BWMWCuY7.js} +797 -622
- package/dist/client/chunks/icons-BWMWCuY7.js.map +1 -0
- package/dist/client/components/QueryBuilder/QueryAnalysisPanel.d.ts +7 -0
- package/dist/client/components/QueryBuilder/ShareWarningModal.d.ts +9 -0
- package/dist/client/components/QueryBuilder/shareUtils.d.ts +59 -0
- package/dist/client/components/QueryBuilder/types.d.ts +85 -1
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +17 -17
- package/dist/server/index.d.ts +159 -0
- package/dist/server/index.js +1816 -1596
- package/package.json +2 -1
- package/dist/adapters/compiler-DP0leK4b.cjs +0 -22
- package/dist/client/chunks/components-Bbd9Us6e.js.map +0 -1
- package/dist/client/chunks/icons-a6fQwcor.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const
|
|
1
|
+
const b = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
|
|
2
2
|
function H(T, E) {
|
|
3
3
|
if (!T || typeof T != "object")
|
|
4
4
|
return !1;
|
|
5
5
|
if (T instanceof E)
|
|
6
6
|
return !0;
|
|
7
|
-
if (!Object.prototype.hasOwnProperty.call(E,
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(E, b))
|
|
8
8
|
throw new Error(
|
|
9
9
|
`Class "${E.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
|
|
10
10
|
);
|
|
11
11
|
let e = Object.getPrototypeOf(T).constructor;
|
|
12
12
|
if (e)
|
|
13
13
|
for (; e; ) {
|
|
14
|
-
if (
|
|
14
|
+
if (b in e && e[b] === E[b])
|
|
15
15
|
return !0;
|
|
16
16
|
e = Object.getPrototypeOf(e);
|
|
17
17
|
}
|
|
@@ -21,7 +21,7 @@ class RE {
|
|
|
21
21
|
constructor(E, e) {
|
|
22
22
|
this.table = E, this.config = e, this.name = e.name, this.keyAsName = e.keyAsName, this.notNull = e.notNull, this.default = e.default, this.defaultFn = e.defaultFn, this.onUpdateFn = e.onUpdateFn, this.hasDefault = e.hasDefault, this.primary = e.primaryKey, this.isUnique = e.isUnique, this.uniqueName = e.uniqueName, this.uniqueType = e.uniqueType, this.dataType = e.dataType, this.columnType = e.columnType, this.generated = e.generated, this.generatedIdentity = e.generatedIdentity;
|
|
23
23
|
}
|
|
24
|
-
static [
|
|
24
|
+
static [b] = "Column";
|
|
25
25
|
name;
|
|
26
26
|
keyAsName;
|
|
27
27
|
primary;
|
|
@@ -50,12 +50,12 @@ class RE {
|
|
|
50
50
|
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const iE = /* @__PURE__ */ Symbol.for("drizzle:Name"),
|
|
54
|
-
function
|
|
55
|
-
return !!T && typeof T == "function" &&
|
|
53
|
+
const iE = /* @__PURE__ */ Symbol.for("drizzle:Name"), RT = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
|
|
54
|
+
function oe(T) {
|
|
55
|
+
return !!T && typeof T == "function" && RT in T && T[RT] === !0;
|
|
56
56
|
}
|
|
57
|
-
class
|
|
58
|
-
static [
|
|
57
|
+
class QT {
|
|
58
|
+
static [b] = "Subquery";
|
|
59
59
|
constructor(E, e, R, A = !1, S = []) {
|
|
60
60
|
this._ = {
|
|
61
61
|
brand: "Subquery",
|
|
@@ -70,23 +70,23 @@ class vT {
|
|
|
70
70
|
// return new SQL([this]);
|
|
71
71
|
// }
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const De = {
|
|
74
74
|
startActiveSpan(T, E) {
|
|
75
75
|
return E();
|
|
76
76
|
}
|
|
77
|
-
}, TE = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig"), aE = /* @__PURE__ */ Symbol.for("drizzle:Schema"),
|
|
78
|
-
class
|
|
79
|
-
static [
|
|
77
|
+
}, TE = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig"), aE = /* @__PURE__ */ Symbol.for("drizzle:Schema"), AT = /* @__PURE__ */ Symbol.for("drizzle:Columns"), ST = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns"), oE = /* @__PURE__ */ Symbol.for("drizzle:OriginalName"), DE = /* @__PURE__ */ Symbol.for("drizzle:BaseName"), sE = /* @__PURE__ */ Symbol.for("drizzle:IsAlias"), NT = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder"), Pe = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
|
|
78
|
+
class W {
|
|
79
|
+
static [b] = "Table";
|
|
80
80
|
/** @internal */
|
|
81
81
|
static Symbol = {
|
|
82
82
|
Name: iE,
|
|
83
83
|
Schema: aE,
|
|
84
84
|
OriginalName: oE,
|
|
85
|
-
Columns:
|
|
86
|
-
ExtraConfigColumns:
|
|
85
|
+
Columns: AT,
|
|
86
|
+
ExtraConfigColumns: ST,
|
|
87
87
|
BaseName: DE,
|
|
88
88
|
IsAlias: sE,
|
|
89
|
-
ExtraConfigBuilder:
|
|
89
|
+
ExtraConfigBuilder: NT
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
92
92
|
* @internal
|
|
@@ -101,9 +101,9 @@ class b {
|
|
|
101
101
|
/** @internal */
|
|
102
102
|
[aE];
|
|
103
103
|
/** @internal */
|
|
104
|
-
[
|
|
104
|
+
[AT];
|
|
105
105
|
/** @internal */
|
|
106
|
-
[
|
|
106
|
+
[ST];
|
|
107
107
|
/**
|
|
108
108
|
* @internal
|
|
109
109
|
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
@@ -112,24 +112,24 @@ class b {
|
|
|
112
112
|
/** @internal */
|
|
113
113
|
[sE] = !1;
|
|
114
114
|
/** @internal */
|
|
115
|
-
[
|
|
115
|
+
[Pe] = !0;
|
|
116
116
|
/** @internal */
|
|
117
|
-
[
|
|
117
|
+
[NT] = void 0;
|
|
118
118
|
constructor(E, e, R) {
|
|
119
119
|
this[iE] = this[oE] = E, this[aE] = e, this[DE] = R;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function ZT(T) {
|
|
123
123
|
return T != null && typeof T.getSQL == "function";
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Me(T) {
|
|
126
126
|
const E = { sql: "", params: [] };
|
|
127
127
|
for (const e of T)
|
|
128
128
|
E.sql += e.sql, E.params.push(...e.params), e.typings?.length && (E.typings || (E.typings = []), E.typings.push(...e.typings));
|
|
129
129
|
return E;
|
|
130
130
|
}
|
|
131
131
|
class f {
|
|
132
|
-
static [
|
|
132
|
+
static [b] = "StringChunk";
|
|
133
133
|
value;
|
|
134
134
|
constructor(E) {
|
|
135
135
|
this.value = Array.isArray(E) ? E : [E];
|
|
@@ -142,16 +142,16 @@ class d {
|
|
|
142
142
|
constructor(E) {
|
|
143
143
|
this.queryChunks = E;
|
|
144
144
|
for (const e of E)
|
|
145
|
-
if (H(e,
|
|
146
|
-
const R = e[
|
|
145
|
+
if (H(e, W)) {
|
|
146
|
+
const R = e[W.Symbol.Schema];
|
|
147
147
|
this.usedTables.push(
|
|
148
|
-
R === void 0 ? e[
|
|
148
|
+
R === void 0 ? e[W.Symbol.Name] : R + "." + e[W.Symbol.Name]
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
static [
|
|
152
|
+
static [b] = "SQL";
|
|
153
153
|
/** @internal */
|
|
154
|
-
decoder =
|
|
154
|
+
decoder = qT;
|
|
155
155
|
shouldInlineParams = !1;
|
|
156
156
|
/** @internal */
|
|
157
157
|
usedTables = [];
|
|
@@ -159,7 +159,7 @@ class d {
|
|
|
159
159
|
return this.queryChunks.push(...E.queryChunks), this;
|
|
160
160
|
}
|
|
161
161
|
toQuery(E) {
|
|
162
|
-
return
|
|
162
|
+
return De.startActiveSpan("drizzle.buildSQL", (e) => {
|
|
163
163
|
const R = this.buildQueryFromSourceParams(this.queryChunks, E);
|
|
164
164
|
return e?.setAttributes({
|
|
165
165
|
"drizzle.query.text": R.sql,
|
|
@@ -179,17 +179,17 @@ class d {
|
|
|
179
179
|
inlineParams: s,
|
|
180
180
|
paramStartIndex: O
|
|
181
181
|
} = R;
|
|
182
|
-
return
|
|
182
|
+
return Me(E.map((N) => {
|
|
183
183
|
if (H(N, f))
|
|
184
184
|
return { sql: N.value.join(""), params: [] };
|
|
185
|
-
if (H(N,
|
|
185
|
+
if (H(N, qE))
|
|
186
186
|
return { sql: S(N.value), params: [] };
|
|
187
187
|
if (N === void 0)
|
|
188
188
|
return { sql: "", params: [] };
|
|
189
189
|
if (Array.isArray(N)) {
|
|
190
190
|
const r = [new f("(")];
|
|
191
|
-
for (const [n,
|
|
192
|
-
r.push(
|
|
191
|
+
for (const [n, C] of N.entries())
|
|
192
|
+
r.push(C), n < N.length - 1 && r.push(new f(", "));
|
|
193
193
|
return r.push(new f(")")), this.buildQueryFromSourceParams(r, R);
|
|
194
194
|
}
|
|
195
195
|
if (H(N, d))
|
|
@@ -197,8 +197,8 @@ class d {
|
|
|
197
197
|
...R,
|
|
198
198
|
inlineParams: s || N.shouldInlineParams
|
|
199
199
|
});
|
|
200
|
-
if (H(N,
|
|
201
|
-
const r = N[
|
|
200
|
+
if (H(N, W)) {
|
|
201
|
+
const r = N[W.Symbol.Schema], n = N[W.Symbol.Name];
|
|
202
202
|
return {
|
|
203
203
|
sql: r === void 0 || N[sE] ? S(n) : S(r) + "." + S(n),
|
|
204
204
|
params: []
|
|
@@ -208,13 +208,13 @@ class d {
|
|
|
208
208
|
const r = A.getColumnCasing(N);
|
|
209
209
|
if (e.invokeSource === "indexes")
|
|
210
210
|
return { sql: S(r), params: [] };
|
|
211
|
-
const n = N.table[
|
|
211
|
+
const n = N.table[W.Symbol.Schema];
|
|
212
212
|
return {
|
|
213
|
-
sql: N.table[sE] || n === void 0 ? S(N.table[
|
|
213
|
+
sql: N.table[sE] || n === void 0 ? S(N.table[W.Symbol.Name]) + "." + S(r) : S(n) + "." + S(N.table[W.Symbol.Name]) + "." + S(r),
|
|
214
214
|
params: []
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
-
if (H(N,
|
|
217
|
+
if (H(N, kT)) {
|
|
218
218
|
const r = N[TE].schema, n = N[TE].name;
|
|
219
219
|
return {
|
|
220
220
|
sql: r === void 0 || N[TE].isAlias ? S(n) : S(r) + "." + S(n),
|
|
@@ -222,7 +222,7 @@ class d {
|
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
if (H(N, rE)) {
|
|
225
|
-
if (H(N.value,
|
|
225
|
+
if (H(N.value, nE))
|
|
226
226
|
return { sql: I(O.value++, N), params: [N], typings: ["none"] };
|
|
227
227
|
const r = N.value === null ? null : N.encoder.mapToDriverValue(N.value);
|
|
228
228
|
if (H(r, d))
|
|
@@ -232,12 +232,12 @@ class d {
|
|
|
232
232
|
let n = ["none"];
|
|
233
233
|
return t && (n = [t(N.encoder)]), { sql: I(O.value++, r), params: [r], typings: n };
|
|
234
234
|
}
|
|
235
|
-
return H(N,
|
|
235
|
+
return H(N, nE) ? { sql: I(O.value++, N), params: [N], typings: ["none"] } : H(N, d.Aliased) && N.fieldAlias !== void 0 ? { sql: S(N.fieldAlias), params: [] } : H(N, QT) ? N._.isWith ? { sql: S(N._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
236
236
|
new f("("),
|
|
237
237
|
N._.sql,
|
|
238
238
|
new f(") "),
|
|
239
|
-
new
|
|
240
|
-
], R) :
|
|
239
|
+
new qE(N._.alias)
|
|
240
|
+
], R) : oe(N) ? N.schema ? { sql: S(N.schema) + "." + S(N.enumName), params: [] } : { sql: S(N.enumName), params: [] } : ZT(N) ? N.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([N.getSQL()], R) : this.buildQueryFromSourceParams([
|
|
241
241
|
new f("("),
|
|
242
242
|
N.getSQL(),
|
|
243
243
|
new f(")")
|
|
@@ -279,43 +279,43 @@ class d {
|
|
|
279
279
|
return E ? this : void 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
class
|
|
282
|
+
class qE {
|
|
283
283
|
constructor(E) {
|
|
284
284
|
this.value = E;
|
|
285
285
|
}
|
|
286
|
-
static [
|
|
286
|
+
static [b] = "Name";
|
|
287
287
|
brand;
|
|
288
288
|
getSQL() {
|
|
289
289
|
return new d([this]);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Ue(T) {
|
|
293
293
|
return typeof T == "object" && T !== null && "mapToDriverValue" in T && typeof T.mapToDriverValue == "function";
|
|
294
294
|
}
|
|
295
|
-
const
|
|
295
|
+
const qT = {
|
|
296
296
|
mapFromDriverValue: (T) => T
|
|
297
|
-
},
|
|
297
|
+
}, jT = {
|
|
298
298
|
mapToDriverValue: (T) => T
|
|
299
299
|
};
|
|
300
300
|
({
|
|
301
|
-
...
|
|
302
|
-
...
|
|
301
|
+
...qT,
|
|
302
|
+
...jT
|
|
303
303
|
});
|
|
304
304
|
class rE {
|
|
305
305
|
/**
|
|
306
306
|
* @param value - Parameter value
|
|
307
307
|
* @param encoder - Encoder to convert the value to a driver parameter
|
|
308
308
|
*/
|
|
309
|
-
constructor(E, e =
|
|
309
|
+
constructor(E, e = jT) {
|
|
310
310
|
this.value = E, this.encoder = e;
|
|
311
311
|
}
|
|
312
|
-
static [
|
|
312
|
+
static [b] = "Param";
|
|
313
313
|
brand;
|
|
314
314
|
getSQL() {
|
|
315
315
|
return new d([this]);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function L(T, ...E) {
|
|
319
319
|
const e = [];
|
|
320
320
|
(E.length > 0 || T.length > 0 && T[0] !== "") && e.push(new f(T[0]));
|
|
321
321
|
for (const [R, A] of E.entries())
|
|
@@ -343,24 +343,24 @@ function C(T, ...E) {
|
|
|
343
343
|
}
|
|
344
344
|
T.join = A;
|
|
345
345
|
function S(s) {
|
|
346
|
-
return new
|
|
346
|
+
return new qE(s);
|
|
347
347
|
}
|
|
348
348
|
T.identifier = S;
|
|
349
349
|
function I(s) {
|
|
350
|
-
return new
|
|
350
|
+
return new nE(s);
|
|
351
351
|
}
|
|
352
352
|
T.placeholder = I;
|
|
353
353
|
function t(s, O) {
|
|
354
354
|
return new rE(s, O);
|
|
355
355
|
}
|
|
356
356
|
T.param = t;
|
|
357
|
-
})(
|
|
357
|
+
})(L || (L = {}));
|
|
358
358
|
((T) => {
|
|
359
359
|
class E {
|
|
360
360
|
constructor(R, A) {
|
|
361
361
|
this.sql = R, this.fieldAlias = A;
|
|
362
362
|
}
|
|
363
|
-
static [
|
|
363
|
+
static [b] = "SQL.Aliased";
|
|
364
364
|
/** @internal */
|
|
365
365
|
isSelectionField = !1;
|
|
366
366
|
getSQL() {
|
|
@@ -373,22 +373,22 @@ function C(T, ...E) {
|
|
|
373
373
|
}
|
|
374
374
|
T.Aliased = E;
|
|
375
375
|
})(d || (d = {}));
|
|
376
|
-
class
|
|
376
|
+
class nE {
|
|
377
377
|
constructor(E) {
|
|
378
378
|
this.name = E;
|
|
379
379
|
}
|
|
380
|
-
static [
|
|
380
|
+
static [b] = "Placeholder";
|
|
381
381
|
getSQL() {
|
|
382
382
|
return new d([this]);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
const
|
|
386
|
-
class
|
|
387
|
-
static [
|
|
385
|
+
const ce = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
|
|
386
|
+
class kT {
|
|
387
|
+
static [b] = "View";
|
|
388
388
|
/** @internal */
|
|
389
389
|
[TE];
|
|
390
390
|
/** @internal */
|
|
391
|
-
[
|
|
391
|
+
[ce] = !0;
|
|
392
392
|
constructor({ name: E, schema: e, selectedFields: R, query: A }) {
|
|
393
393
|
this[TE] = {
|
|
394
394
|
name: E,
|
|
@@ -407,16 +407,16 @@ class jT {
|
|
|
407
407
|
RE.prototype.getSQL = function() {
|
|
408
408
|
return new d([this]);
|
|
409
409
|
};
|
|
410
|
-
|
|
410
|
+
W.prototype.getSQL = function() {
|
|
411
411
|
return new d([this]);
|
|
412
412
|
};
|
|
413
|
-
|
|
413
|
+
QT.prototype.getSQL = function() {
|
|
414
414
|
return new d([this]);
|
|
415
415
|
};
|
|
416
416
|
function h(T, E) {
|
|
417
|
-
return
|
|
417
|
+
return Ue(E) && !ZT(T) && !H(T, rE) && !H(T, nE) && !H(T, RE) && !H(T, W) && !H(T, kT) ? new rE(T, E) : T;
|
|
418
418
|
}
|
|
419
|
-
const k = (T, E) =>
|
|
419
|
+
const k = (T, E) => L`${T} = ${h(E, T)}`, IT = (T, E) => L`${T} <> ${h(E, T)}`;
|
|
420
420
|
function V(...T) {
|
|
421
421
|
const E = T.filter(
|
|
422
422
|
(e) => e !== void 0
|
|
@@ -424,7 +424,7 @@ function V(...T) {
|
|
|
424
424
|
if (E.length !== 0)
|
|
425
425
|
return E.length === 1 ? new d(E) : new d([
|
|
426
426
|
new f("("),
|
|
427
|
-
|
|
427
|
+
L.join(E, new f(" and ")),
|
|
428
428
|
new f(")")
|
|
429
429
|
]);
|
|
430
430
|
}
|
|
@@ -435,72 +435,72 @@ function PE(...T) {
|
|
|
435
435
|
if (E.length !== 0)
|
|
436
436
|
return E.length === 1 ? new d(E) : new d([
|
|
437
437
|
new f("("),
|
|
438
|
-
|
|
438
|
+
L.join(E, new f(" or ")),
|
|
439
439
|
new f(")")
|
|
440
440
|
]);
|
|
441
441
|
}
|
|
442
|
-
const ME = (T, E) =>
|
|
442
|
+
const ME = (T, E) => L`${T} > ${h(E, T)}`, Q = (T, E) => L`${T} >= ${h(E, T)}`, UE = (T, E) => L`${T} < ${h(E, T)}`, Z = (T, E) => L`${T} <= ${h(E, T)}`;
|
|
443
443
|
function cE(T, E) {
|
|
444
|
-
return Array.isArray(E) ? E.length === 0 ?
|
|
444
|
+
return Array.isArray(E) ? E.length === 0 ? L`false` : L`${T} in ${E.map((e) => h(e, T))}` : L`${T} in ${h(E, T)}`;
|
|
445
445
|
}
|
|
446
|
-
function
|
|
447
|
-
return Array.isArray(E) ? E.length === 0 ?
|
|
446
|
+
function OT(T, E) {
|
|
447
|
+
return Array.isArray(E) ? E.length === 0 ? L`true` : L`${T} not in ${E.map((e) => h(e, T))}` : L`${T} not in ${h(E, T)}`;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
449
|
+
function tT(T) {
|
|
450
|
+
return L`${T} is null`;
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
452
|
+
function sT(T) {
|
|
453
|
+
return L`${T} is not null`;
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function le(T, E) {
|
|
456
456
|
if (Array.isArray(E)) {
|
|
457
457
|
if (E.length === 0)
|
|
458
458
|
throw new Error("arrayContains requires at least one value");
|
|
459
|
-
const e =
|
|
460
|
-
return
|
|
459
|
+
const e = L`${h(E, T)}`;
|
|
460
|
+
return L`${T} @> ${e}`;
|
|
461
461
|
}
|
|
462
|
-
return
|
|
462
|
+
return L`${T} @> ${h(E, T)}`;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function ue(T, E) {
|
|
465
465
|
if (Array.isArray(E)) {
|
|
466
466
|
if (E.length === 0)
|
|
467
467
|
throw new Error("arrayContained requires at least one value");
|
|
468
|
-
const e =
|
|
469
|
-
return
|
|
468
|
+
const e = L`${h(E, T)}`;
|
|
469
|
+
return L`${T} <@ ${e}`;
|
|
470
470
|
}
|
|
471
|
-
return
|
|
471
|
+
return L`${T} <@ ${h(E, T)}`;
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function Ge(T, E) {
|
|
474
474
|
if (Array.isArray(E)) {
|
|
475
475
|
if (E.length === 0)
|
|
476
476
|
throw new Error("arrayOverlaps requires at least one value");
|
|
477
|
-
const e =
|
|
478
|
-
return
|
|
477
|
+
const e = L`${h(E, T)}`;
|
|
478
|
+
return L`${T} && ${e}`;
|
|
479
479
|
}
|
|
480
|
-
return
|
|
480
|
+
return L`${T} && ${h(E, T)}`;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
482
|
+
function rT(T) {
|
|
483
|
+
return L`${T} asc`;
|
|
484
484
|
}
|
|
485
|
-
function
|
|
486
|
-
return
|
|
485
|
+
function me(T) {
|
|
486
|
+
return L`${T} desc`;
|
|
487
487
|
}
|
|
488
488
|
function lE(T) {
|
|
489
|
-
return
|
|
489
|
+
return L`count(${T || L.raw("*")})`.mapWith(Number);
|
|
490
490
|
}
|
|
491
|
-
function
|
|
492
|
-
return
|
|
491
|
+
function de(T) {
|
|
492
|
+
return L`count(distinct ${T})`.mapWith(Number);
|
|
493
493
|
}
|
|
494
494
|
function g(T) {
|
|
495
|
-
return
|
|
495
|
+
return L`sum(${T})`.mapWith(String);
|
|
496
496
|
}
|
|
497
497
|
function AE(T) {
|
|
498
|
-
return
|
|
498
|
+
return L`max(${T})`.mapWith(H(T, RE) ? T : String);
|
|
499
499
|
}
|
|
500
500
|
function SE(T) {
|
|
501
|
-
return
|
|
501
|
+
return L`min(${T})`.mapWith(H(T, RE) ? T : String);
|
|
502
502
|
}
|
|
503
|
-
class
|
|
503
|
+
class zE {
|
|
504
504
|
/**
|
|
505
505
|
* Default implementation returns template unchanged
|
|
506
506
|
* Override in specific adapters for database-specific preprocessing
|
|
@@ -526,7 +526,7 @@ class jE {
|
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
class
|
|
529
|
+
class He extends zE {
|
|
530
530
|
getEngineType() {
|
|
531
531
|
return "postgres";
|
|
532
532
|
}
|
|
@@ -537,21 +537,21 @@ class de extends jE {
|
|
|
537
537
|
buildTimeDimension(E, e) {
|
|
538
538
|
switch (E) {
|
|
539
539
|
case "year":
|
|
540
|
-
return
|
|
540
|
+
return L`DATE_TRUNC('year', ${e}::timestamp)`;
|
|
541
541
|
case "quarter":
|
|
542
|
-
return
|
|
542
|
+
return L`DATE_TRUNC('quarter', ${e}::timestamp)`;
|
|
543
543
|
case "month":
|
|
544
|
-
return
|
|
544
|
+
return L`DATE_TRUNC('month', ${e}::timestamp)`;
|
|
545
545
|
case "week":
|
|
546
|
-
return
|
|
546
|
+
return L`DATE_TRUNC('week', ${e}::timestamp)`;
|
|
547
547
|
case "day":
|
|
548
|
-
return
|
|
548
|
+
return L`DATE_TRUNC('day', ${e}::timestamp)::timestamp`;
|
|
549
549
|
case "hour":
|
|
550
|
-
return
|
|
550
|
+
return L`DATE_TRUNC('hour', ${e}::timestamp)`;
|
|
551
551
|
case "minute":
|
|
552
|
-
return
|
|
552
|
+
return L`DATE_TRUNC('minute', ${e}::timestamp)`;
|
|
553
553
|
case "second":
|
|
554
|
-
return
|
|
554
|
+
return L`DATE_TRUNC('second', ${e}::timestamp)`;
|
|
555
555
|
default:
|
|
556
556
|
return e;
|
|
557
557
|
}
|
|
@@ -563,23 +563,23 @@ class de extends jE {
|
|
|
563
563
|
buildStringCondition(E, e, R) {
|
|
564
564
|
switch (e) {
|
|
565
565
|
case "contains":
|
|
566
|
-
return
|
|
566
|
+
return L`${E} ILIKE ${`%${R}%`}`;
|
|
567
567
|
case "notContains":
|
|
568
|
-
return
|
|
568
|
+
return L`${E} NOT ILIKE ${`%${R}%`}`;
|
|
569
569
|
case "startsWith":
|
|
570
|
-
return
|
|
570
|
+
return L`${E} ILIKE ${`${R}%`}`;
|
|
571
571
|
case "endsWith":
|
|
572
|
-
return
|
|
572
|
+
return L`${E} ILIKE ${`%${R}`}`;
|
|
573
573
|
case "like":
|
|
574
|
-
return
|
|
574
|
+
return L`${E} LIKE ${R}`;
|
|
575
575
|
case "notLike":
|
|
576
|
-
return
|
|
576
|
+
return L`${E} NOT LIKE ${R}`;
|
|
577
577
|
case "ilike":
|
|
578
|
-
return
|
|
578
|
+
return L`${E} ILIKE ${R}`;
|
|
579
579
|
case "regex":
|
|
580
|
-
return
|
|
580
|
+
return L`${E} ~* ${R}`;
|
|
581
581
|
case "notRegex":
|
|
582
|
-
return
|
|
582
|
+
return L`${E} !~* ${R}`;
|
|
583
583
|
default:
|
|
584
584
|
throw new Error(`Unsupported string operator: ${e}`);
|
|
585
585
|
}
|
|
@@ -591,11 +591,11 @@ class de extends jE {
|
|
|
591
591
|
castToType(E, e) {
|
|
592
592
|
switch (e) {
|
|
593
593
|
case "timestamp":
|
|
594
|
-
return
|
|
594
|
+
return L`${E}::timestamp`;
|
|
595
595
|
case "decimal":
|
|
596
|
-
return
|
|
596
|
+
return L`${E}::decimal`;
|
|
597
597
|
case "integer":
|
|
598
|
-
return
|
|
598
|
+
return L`${E}::integer`;
|
|
599
599
|
default:
|
|
600
600
|
throw new Error(`Unsupported cast type: ${e}`);
|
|
601
601
|
}
|
|
@@ -606,21 +606,21 @@ class de extends jE {
|
|
|
606
606
|
* Extracted from multi-cube-builder.ts:284
|
|
607
607
|
*/
|
|
608
608
|
buildAvg(E) {
|
|
609
|
-
return
|
|
609
|
+
return L`COALESCE(AVG(${E}), 0)`;
|
|
610
610
|
}
|
|
611
611
|
/**
|
|
612
612
|
* Build PostgreSQL CASE WHEN conditional expression
|
|
613
613
|
*/
|
|
614
614
|
buildCaseWhen(E, e) {
|
|
615
|
-
const R = E.map((A) =>
|
|
616
|
-
return e !== void 0 ?
|
|
615
|
+
const R = E.map((A) => L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
|
|
616
|
+
return e !== void 0 ? L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
|
|
617
617
|
}
|
|
618
618
|
/**
|
|
619
619
|
* Build PostgreSQL boolean literal
|
|
620
620
|
* PostgreSQL uses TRUE/FALSE keywords
|
|
621
621
|
*/
|
|
622
622
|
buildBooleanLiteral(E) {
|
|
623
|
-
return E ?
|
|
623
|
+
return E ? L`TRUE` : L`FALSE`;
|
|
624
624
|
}
|
|
625
625
|
/**
|
|
626
626
|
* Convert filter values - PostgreSQL uses native types
|
|
@@ -650,7 +650,7 @@ class de extends jE {
|
|
|
650
650
|
return E;
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
class
|
|
653
|
+
class zT extends zE {
|
|
654
654
|
getEngineType() {
|
|
655
655
|
return "mysql";
|
|
656
656
|
}
|
|
@@ -673,12 +673,12 @@ class kT extends jE {
|
|
|
673
673
|
};
|
|
674
674
|
switch (E) {
|
|
675
675
|
case "quarter":
|
|
676
|
-
return
|
|
676
|
+
return L`DATE_ADD(MAKEDATE(YEAR(${e}), 1), INTERVAL (QUARTER(${e}) - 1) * 3 MONTH)`;
|
|
677
677
|
case "week":
|
|
678
|
-
return
|
|
678
|
+
return L`DATE_SUB(${e}, INTERVAL WEEKDAY(${e}) DAY)`;
|
|
679
679
|
default:
|
|
680
680
|
const A = R[E];
|
|
681
|
-
return A ?
|
|
681
|
+
return A ? L`STR_TO_DATE(DATE_FORMAT(${e}, ${A}), '%Y-%m-%d %H:%i:%s')` : e;
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
/**
|
|
@@ -689,23 +689,23 @@ class kT extends jE {
|
|
|
689
689
|
buildStringCondition(E, e, R) {
|
|
690
690
|
switch (e) {
|
|
691
691
|
case "contains":
|
|
692
|
-
return
|
|
692
|
+
return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
|
|
693
693
|
case "notContains":
|
|
694
|
-
return
|
|
694
|
+
return L`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
|
|
695
695
|
case "startsWith":
|
|
696
|
-
return
|
|
696
|
+
return L`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
|
|
697
697
|
case "endsWith":
|
|
698
|
-
return
|
|
698
|
+
return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
|
|
699
699
|
case "like":
|
|
700
|
-
return
|
|
700
|
+
return L`${E} LIKE ${R}`;
|
|
701
701
|
case "notLike":
|
|
702
|
-
return
|
|
702
|
+
return L`${E} NOT LIKE ${R}`;
|
|
703
703
|
case "ilike":
|
|
704
|
-
return
|
|
704
|
+
return L`LOWER(${E}) LIKE ${R.toLowerCase()}`;
|
|
705
705
|
case "regex":
|
|
706
|
-
return
|
|
706
|
+
return L`${E} REGEXP ${R}`;
|
|
707
707
|
case "notRegex":
|
|
708
|
-
return
|
|
708
|
+
return L`${E} NOT REGEXP ${R}`;
|
|
709
709
|
default:
|
|
710
710
|
throw new Error(`Unsupported string operator: ${e}`);
|
|
711
711
|
}
|
|
@@ -717,11 +717,11 @@ class kT extends jE {
|
|
|
717
717
|
castToType(E, e) {
|
|
718
718
|
switch (e) {
|
|
719
719
|
case "timestamp":
|
|
720
|
-
return
|
|
720
|
+
return L`CAST(${E} AS DATETIME)`;
|
|
721
721
|
case "decimal":
|
|
722
|
-
return
|
|
722
|
+
return L`CAST(${E} AS DECIMAL(10,2))`;
|
|
723
723
|
case "integer":
|
|
724
|
-
return
|
|
724
|
+
return L`CAST(${E} AS SIGNED INTEGER)`;
|
|
725
725
|
default:
|
|
726
726
|
throw new Error(`Unsupported cast type: ${e}`);
|
|
727
727
|
}
|
|
@@ -731,21 +731,21 @@ class kT extends jE {
|
|
|
731
731
|
* MySQL AVG returns NULL for empty sets, using IFNULL for consistency
|
|
732
732
|
*/
|
|
733
733
|
buildAvg(E) {
|
|
734
|
-
return
|
|
734
|
+
return L`IFNULL(AVG(${E}), 0)`;
|
|
735
735
|
}
|
|
736
736
|
/**
|
|
737
737
|
* Build MySQL CASE WHEN conditional expression
|
|
738
738
|
*/
|
|
739
739
|
buildCaseWhen(E, e) {
|
|
740
|
-
const R = E.map((A) =>
|
|
741
|
-
return e !== void 0 ?
|
|
740
|
+
const R = E.map((A) => L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
|
|
741
|
+
return e !== void 0 ? L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
|
|
742
742
|
}
|
|
743
743
|
/**
|
|
744
744
|
* Build MySQL boolean literal
|
|
745
745
|
* MySQL uses TRUE/FALSE keywords (equivalent to 1/0)
|
|
746
746
|
*/
|
|
747
747
|
buildBooleanLiteral(E) {
|
|
748
|
-
return E ?
|
|
748
|
+
return E ? L`TRUE` : L`FALSE`;
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
751
|
* Convert filter values - MySQL uses native types
|
|
@@ -775,7 +775,7 @@ class kT extends jE {
|
|
|
775
775
|
return E;
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
class
|
|
778
|
+
class pe extends zE {
|
|
779
779
|
getEngineType() {
|
|
780
780
|
return "sqlite";
|
|
781
781
|
}
|
|
@@ -788,28 +788,28 @@ class He extends jE {
|
|
|
788
788
|
buildTimeDimension(E, e) {
|
|
789
789
|
switch (E) {
|
|
790
790
|
case "year":
|
|
791
|
-
return
|
|
791
|
+
return L`datetime(${e}, 'unixepoch', 'start of year')`;
|
|
792
792
|
case "quarter":
|
|
793
|
-
const R =
|
|
794
|
-
return
|
|
793
|
+
const R = L`datetime(${e}, 'unixepoch')`;
|
|
794
|
+
return L`datetime(${R}, 'start of year',
|
|
795
795
|
'+' || (((CAST(strftime('%m', ${R}) AS INTEGER) - 1) / 3) * 3) || ' months')`;
|
|
796
796
|
case "month":
|
|
797
|
-
return
|
|
797
|
+
return L`datetime(${e}, 'unixepoch', 'start of month')`;
|
|
798
798
|
case "week":
|
|
799
|
-
return
|
|
799
|
+
return L`date(datetime(${e}, 'unixepoch'), 'weekday 1', '-6 days')`;
|
|
800
800
|
case "day":
|
|
801
|
-
return
|
|
801
|
+
return L`datetime(${e}, 'unixepoch', 'start of day')`;
|
|
802
802
|
case "hour":
|
|
803
|
-
const A =
|
|
804
|
-
return
|
|
803
|
+
const A = L`datetime(${e}, 'unixepoch')`;
|
|
804
|
+
return L`datetime(strftime('%Y-%m-%d %H:00:00', ${A}))`;
|
|
805
805
|
case "minute":
|
|
806
|
-
const S =
|
|
807
|
-
return
|
|
806
|
+
const S = L`datetime(${e}, 'unixepoch')`;
|
|
807
|
+
return L`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
|
|
808
808
|
case "second":
|
|
809
|
-
const I =
|
|
810
|
-
return
|
|
809
|
+
const I = L`datetime(${e}, 'unixepoch')`;
|
|
810
|
+
return L`datetime(strftime('%Y-%m-%d %H:%M:%S', ${I}))`;
|
|
811
811
|
default:
|
|
812
|
-
return
|
|
812
|
+
return L`datetime(${e}, 'unixepoch')`;
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
/**
|
|
@@ -819,23 +819,23 @@ class He extends jE {
|
|
|
819
819
|
buildStringCondition(E, e, R) {
|
|
820
820
|
switch (e) {
|
|
821
821
|
case "contains":
|
|
822
|
-
return
|
|
822
|
+
return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
|
|
823
823
|
case "notContains":
|
|
824
|
-
return
|
|
824
|
+
return L`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
|
|
825
825
|
case "startsWith":
|
|
826
|
-
return
|
|
826
|
+
return L`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
|
|
827
827
|
case "endsWith":
|
|
828
|
-
return
|
|
828
|
+
return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
|
|
829
829
|
case "like":
|
|
830
|
-
return
|
|
830
|
+
return L`${E} LIKE ${R}`;
|
|
831
831
|
case "notLike":
|
|
832
|
-
return
|
|
832
|
+
return L`${E} NOT LIKE ${R}`;
|
|
833
833
|
case "ilike":
|
|
834
|
-
return
|
|
834
|
+
return L`LOWER(${E}) LIKE ${R.toLowerCase()}`;
|
|
835
835
|
case "regex":
|
|
836
|
-
return
|
|
836
|
+
return L`${E} GLOB ${R}`;
|
|
837
837
|
case "notRegex":
|
|
838
|
-
return
|
|
838
|
+
return L`${E} NOT GLOB ${R}`;
|
|
839
839
|
default:
|
|
840
840
|
throw new Error(`Unsupported string operator: ${e}`);
|
|
841
841
|
}
|
|
@@ -847,11 +847,11 @@ class He extends jE {
|
|
|
847
847
|
castToType(E, e) {
|
|
848
848
|
switch (e) {
|
|
849
849
|
case "timestamp":
|
|
850
|
-
return
|
|
850
|
+
return L`datetime(${E} / 1000, 'unixepoch')`;
|
|
851
851
|
case "decimal":
|
|
852
|
-
return
|
|
852
|
+
return L`CAST(${E} AS REAL)`;
|
|
853
853
|
case "integer":
|
|
854
|
-
return
|
|
854
|
+
return L`CAST(${E} AS INTEGER)`;
|
|
855
855
|
default:
|
|
856
856
|
throw new Error(`Unsupported cast type: ${e}`);
|
|
857
857
|
}
|
|
@@ -861,21 +861,21 @@ class He extends jE {
|
|
|
861
861
|
* SQLite AVG returns NULL for empty sets, using IFNULL for consistency
|
|
862
862
|
*/
|
|
863
863
|
buildAvg(E) {
|
|
864
|
-
return
|
|
864
|
+
return L`IFNULL(AVG(${E}), 0)`;
|
|
865
865
|
}
|
|
866
866
|
/**
|
|
867
867
|
* Build SQLite CASE WHEN conditional expression
|
|
868
868
|
*/
|
|
869
869
|
buildCaseWhen(E, e) {
|
|
870
|
-
const R = E.map((A) => A.then && typeof A.then == "object" && (A.then.queryChunks || A.then._ || A.then.sql) ?
|
|
871
|
-
return e !== void 0 ? e && typeof e == "object" && (e.queryChunks || e._ || e.sql) ?
|
|
870
|
+
const R = E.map((A) => A.then && typeof A.then == "object" && (A.then.queryChunks || A.then._ || A.then.sql) ? L`WHEN ${A.when} THEN ${L.raw("(")}${A.then}${L.raw(")")}` : L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
|
|
871
|
+
return e !== void 0 ? e && typeof e == "object" && (e.queryChunks || e._ || e.sql) ? L`CASE ${R} ELSE ${L.raw("(")}${e}${L.raw(")")} END` : L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
|
|
872
872
|
}
|
|
873
873
|
/**
|
|
874
874
|
* Build SQLite boolean literal
|
|
875
875
|
* SQLite uses 1/0 for true/false
|
|
876
876
|
*/
|
|
877
877
|
buildBooleanLiteral(E) {
|
|
878
|
-
return E ?
|
|
878
|
+
return E ? L`1` : L`0`;
|
|
879
879
|
}
|
|
880
880
|
/**
|
|
881
881
|
* Preprocess calculated measure templates for SQLite-specific handling
|
|
@@ -927,7 +927,7 @@ class He extends jE {
|
|
|
927
927
|
return E;
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
|
-
class Be extends
|
|
930
|
+
class Be extends zT {
|
|
931
931
|
getEngineType() {
|
|
932
932
|
return "singlestore";
|
|
933
933
|
}
|
|
@@ -940,29 +940,29 @@ class Be extends kT {
|
|
|
940
940
|
// These limitations are typically handled at the query building level
|
|
941
941
|
// rather than in the adapter, but can be addressed here if needed
|
|
942
942
|
}
|
|
943
|
-
function
|
|
943
|
+
function Fe(T) {
|
|
944
944
|
switch (T) {
|
|
945
945
|
case "postgres":
|
|
946
|
-
return new
|
|
946
|
+
return new He();
|
|
947
947
|
case "mysql":
|
|
948
|
-
return new
|
|
948
|
+
return new zT();
|
|
949
949
|
case "sqlite":
|
|
950
|
-
return new
|
|
950
|
+
return new pe();
|
|
951
951
|
case "singlestore":
|
|
952
952
|
return new Be();
|
|
953
953
|
default:
|
|
954
954
|
throw new Error(`Unsupported database engine: ${T}`);
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
|
-
class
|
|
957
|
+
class ET {
|
|
958
958
|
constructor(E, e, R) {
|
|
959
959
|
this.db = E, this.schema = e;
|
|
960
960
|
const A = R || this.getEngineType();
|
|
961
|
-
this.databaseAdapter =
|
|
961
|
+
this.databaseAdapter = Fe(A);
|
|
962
962
|
}
|
|
963
963
|
databaseAdapter;
|
|
964
964
|
}
|
|
965
|
-
class
|
|
965
|
+
class Ye extends ET {
|
|
966
966
|
async execute(E, e) {
|
|
967
967
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
968
968
|
const A = await E.execute();
|
|
@@ -1013,10 +1013,10 @@ class Fe extends kE {
|
|
|
1013
1013
|
return "postgres";
|
|
1014
1014
|
}
|
|
1015
1015
|
}
|
|
1016
|
-
function
|
|
1017
|
-
return new
|
|
1016
|
+
function nT(T, E) {
|
|
1017
|
+
return new Ye(T, E, "postgres");
|
|
1018
1018
|
}
|
|
1019
|
-
class
|
|
1019
|
+
class Ee extends ET {
|
|
1020
1020
|
async execute(E, e) {
|
|
1021
1021
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
1022
1022
|
const A = await E.execute();
|
|
@@ -1054,10 +1054,10 @@ class zT extends kE {
|
|
|
1054
1054
|
return "mysql";
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
-
function
|
|
1058
|
-
return new
|
|
1057
|
+
function fe(T, E) {
|
|
1058
|
+
return new Ee(T, E, "mysql");
|
|
1059
1059
|
}
|
|
1060
|
-
class
|
|
1060
|
+
class he extends ET {
|
|
1061
1061
|
async execute(E, e) {
|
|
1062
1062
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
1063
1063
|
const R = await E.execute();
|
|
@@ -1103,10 +1103,10 @@ class fe extends kE {
|
|
|
1103
1103
|
return "sqlite";
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
|
-
function
|
|
1107
|
-
return new
|
|
1106
|
+
function CT(T, E) {
|
|
1107
|
+
return new he(T, E, "sqlite");
|
|
1108
1108
|
}
|
|
1109
|
-
class
|
|
1109
|
+
class Ve extends Ee {
|
|
1110
1110
|
getEngineType() {
|
|
1111
1111
|
return "singlestore";
|
|
1112
1112
|
}
|
|
@@ -1114,31 +1114,31 @@ class he extends zT {
|
|
|
1114
1114
|
// For now, we inherit all behavior from MySQLExecutor since
|
|
1115
1115
|
// SingleStore is largely MySQL-compatible
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1118
|
-
return new
|
|
1117
|
+
function be(T, E) {
|
|
1118
|
+
return new Ve(T, E);
|
|
1119
1119
|
}
|
|
1120
|
-
function
|
|
1120
|
+
function LT(T, E, e) {
|
|
1121
1121
|
if (e)
|
|
1122
1122
|
switch (e) {
|
|
1123
1123
|
case "postgres":
|
|
1124
|
-
return
|
|
1124
|
+
return nT(T, E);
|
|
1125
1125
|
case "mysql":
|
|
1126
|
-
return
|
|
1126
|
+
return fe(T, E);
|
|
1127
1127
|
case "sqlite":
|
|
1128
|
-
return
|
|
1128
|
+
return CT(T, E);
|
|
1129
1129
|
case "singlestore":
|
|
1130
|
-
return
|
|
1130
|
+
return be(T, E);
|
|
1131
1131
|
}
|
|
1132
1132
|
if (T.all && T.run)
|
|
1133
|
-
return
|
|
1133
|
+
return CT(T, E);
|
|
1134
1134
|
if (T.execute)
|
|
1135
|
-
return
|
|
1135
|
+
return nT(T, E);
|
|
1136
1136
|
throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1138
|
+
function uE(T) {
|
|
1139
1139
|
return typeof T == "function" ? T() : T;
|
|
1140
1140
|
}
|
|
1141
|
-
function
|
|
1141
|
+
function jE(T, E) {
|
|
1142
1142
|
if (E) return E;
|
|
1143
1143
|
switch (T) {
|
|
1144
1144
|
case "belongsTo":
|
|
@@ -1158,13 +1158,13 @@ function Ee(T, E) {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
}
|
|
1160
1160
|
function We(T) {
|
|
1161
|
-
return T && typeof T == "object" ?
|
|
1161
|
+
return T && typeof T == "object" ? L`${L`${T}`}` : T;
|
|
1162
1162
|
}
|
|
1163
1163
|
function w(T, E) {
|
|
1164
1164
|
const e = typeof T == "function" ? T(E) : T;
|
|
1165
1165
|
return We(e);
|
|
1166
1166
|
}
|
|
1167
|
-
function
|
|
1167
|
+
function ye(T, E) {
|
|
1168
1168
|
if (T.relationship !== "belongsToMany" || !T.through)
|
|
1169
1169
|
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
1170
1170
|
const { table: e, sourceKey: R, targetKey: A, securitySql: S } = T.through, I = [];
|
|
@@ -1182,7 +1182,7 @@ function be(T, E) {
|
|
|
1182
1182
|
const N = S(E);
|
|
1183
1183
|
s = Array.isArray(N) ? N : [N];
|
|
1184
1184
|
}
|
|
1185
|
-
const O =
|
|
1185
|
+
const O = jE("belongsToMany", T.sqlJoinType);
|
|
1186
1186
|
return {
|
|
1187
1187
|
junctionJoins: [
|
|
1188
1188
|
{
|
|
@@ -1421,39 +1421,39 @@ class J {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
1423
|
function Xe(T, E) {
|
|
1424
|
-
const { cube: e, allCubes: R, resolvedMeasures: A } = E, S =
|
|
1424
|
+
const { cube: e, allCubes: R, resolvedMeasures: A } = E, S = TT(T), I = /* @__PURE__ */ new Map();
|
|
1425
1425
|
for (const r of S) {
|
|
1426
|
-
const { originalRef: n, cubeName:
|
|
1427
|
-
if (!R.get(
|
|
1426
|
+
const { originalRef: n, cubeName: C, fieldName: i } = r, a = C || e.name;
|
|
1427
|
+
if (!R.get(a))
|
|
1428
1428
|
throw new Error(
|
|
1429
|
-
`Cannot substitute {${n}}: cube '${
|
|
1429
|
+
`Cannot substitute {${n}}: cube '${a}' not found`
|
|
1430
1430
|
);
|
|
1431
|
-
const P = `${
|
|
1431
|
+
const P = `${a}.${i}`, U = A.get(P);
|
|
1432
1432
|
if (!U)
|
|
1433
1433
|
throw new Error(
|
|
1434
1434
|
`Cannot substitute {${n}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
1435
1435
|
);
|
|
1436
|
-
const M = U(), G =
|
|
1436
|
+
const M = U(), G = L`${M}`;
|
|
1437
1437
|
I.set(n, G);
|
|
1438
1438
|
}
|
|
1439
1439
|
const t = [], s = [];
|
|
1440
1440
|
let O = 0;
|
|
1441
1441
|
for (const r of S) {
|
|
1442
|
-
const n = `{${r.originalRef}}`,
|
|
1443
|
-
if (
|
|
1444
|
-
t.push(T.substring(O,
|
|
1442
|
+
const n = `{${r.originalRef}}`, C = T.indexOf(n, O);
|
|
1443
|
+
if (C >= 0) {
|
|
1444
|
+
t.push(T.substring(O, C));
|
|
1445
1445
|
const i = I.get(r.originalRef);
|
|
1446
|
-
i && s.push(i), O =
|
|
1446
|
+
i && s.push(i), O = C + n.length;
|
|
1447
1447
|
}
|
|
1448
1448
|
}
|
|
1449
1449
|
if (t.push(T.substring(O)), s.length === 0)
|
|
1450
|
-
return
|
|
1450
|
+
return L.raw(T);
|
|
1451
1451
|
const N = [];
|
|
1452
1452
|
for (let r = 0; r < t.length; r++)
|
|
1453
1453
|
t[r] && N.push(new f(t[r])), r < s.length && N.push(s[r]);
|
|
1454
|
-
return
|
|
1454
|
+
return L.join(N, L.raw(""));
|
|
1455
1455
|
}
|
|
1456
|
-
function
|
|
1456
|
+
function TT(T) {
|
|
1457
1457
|
const E = /\{([^}]+)\}/g, e = T.matchAll(E), R = [];
|
|
1458
1458
|
for (const A of e) {
|
|
1459
1459
|
const S = A[1].trim();
|
|
@@ -1473,7 +1473,7 @@ function zE(T) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
return R;
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function ge(T) {
|
|
1477
1477
|
const E = [];
|
|
1478
1478
|
let e = 0;
|
|
1479
1479
|
for (let I = 0; I < T.length; I++)
|
|
@@ -1484,7 +1484,7 @@ function ye(T) {
|
|
|
1484
1484
|
break;
|
|
1485
1485
|
}
|
|
1486
1486
|
e > 0 && E.push("Unmatched opening brace in template"), /\{\s*\}/.test(T) && E.push("Empty member reference {} found in template"), /\{[^}]*\{/.test(T) && E.push("Nested braces are not allowed in member references");
|
|
1487
|
-
const S =
|
|
1487
|
+
const S = TT(T);
|
|
1488
1488
|
for (const I of S) {
|
|
1489
1489
|
const t = I.cubeName ? `${I.cubeName}.${I.fieldName}` : I.fieldName;
|
|
1490
1490
|
/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t) || E.push(
|
|
@@ -1498,15 +1498,15 @@ function ye(T) {
|
|
|
1498
1498
|
errors: E
|
|
1499
1499
|
};
|
|
1500
1500
|
}
|
|
1501
|
-
function
|
|
1502
|
-
const e =
|
|
1501
|
+
function GE(T, E) {
|
|
1502
|
+
const e = TT(T), R = /* @__PURE__ */ new Set();
|
|
1503
1503
|
for (const A of e) {
|
|
1504
1504
|
const I = `${A.cubeName || E}.${A.fieldName}`;
|
|
1505
1505
|
R.add(I);
|
|
1506
1506
|
}
|
|
1507
1507
|
return Array.from(R);
|
|
1508
1508
|
}
|
|
1509
|
-
class
|
|
1509
|
+
class Ke {
|
|
1510
1510
|
constructor(E) {
|
|
1511
1511
|
this.databaseAdapter = E;
|
|
1512
1512
|
}
|
|
@@ -1526,39 +1526,39 @@ class ge {
|
|
|
1526
1526
|
for (const N of e.values())
|
|
1527
1527
|
O.buildGraph(N);
|
|
1528
1528
|
for (const N of E) {
|
|
1529
|
-
const [r, n] = N.split("."),
|
|
1530
|
-
if (
|
|
1531
|
-
const i =
|
|
1532
|
-
J.isCalculatedMeasure(i) ? (t.push(N),
|
|
1529
|
+
const [r, n] = N.split("."), C = e.get(r);
|
|
1530
|
+
if (C && C.measures && C.measures[n]) {
|
|
1531
|
+
const i = C.measures[n];
|
|
1532
|
+
J.isCalculatedMeasure(i) ? (t.push(N), GE(i.calculatedSql, r).forEach((P) => s.add(P)), O.getAllDependencies(N).forEach((P) => {
|
|
1533
1533
|
const [U, M] = P.split("."), G = e.get(U);
|
|
1534
1534
|
if (G && G.measures[M]) {
|
|
1535
1535
|
const m = G.measures[M];
|
|
1536
|
-
J.isCalculatedMeasure(m) &&
|
|
1536
|
+
J.isCalculatedMeasure(m) && GE(m.calculatedSql, U).forEach((y) => s.add(y));
|
|
1537
1537
|
}
|
|
1538
1538
|
})) : I.push(N);
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
for (const N of s) {
|
|
1542
|
-
const [r, n] = N.split("."),
|
|
1543
|
-
if (
|
|
1544
|
-
const i =
|
|
1542
|
+
const [r, n] = N.split("."), C = e.get(r);
|
|
1543
|
+
if (C && C.measures && C.measures[n]) {
|
|
1544
|
+
const i = C.measures[n];
|
|
1545
1545
|
J.isCalculatedMeasure(i) ? t.includes(N) || t.push(N) : I.includes(N) || I.push(N);
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
1548
|
for (const N of I) {
|
|
1549
|
-
const [r, n] = N.split("."),
|
|
1549
|
+
const [r, n] = N.split("."), C = e.get(r), i = C.measures[n];
|
|
1550
1550
|
if (A) {
|
|
1551
|
-
const
|
|
1552
|
-
S.set(N, () =>
|
|
1551
|
+
const a = A(N, i, C);
|
|
1552
|
+
S.set(N, () => a);
|
|
1553
1553
|
} else
|
|
1554
1554
|
S.set(N, () => this.buildMeasureExpression(i, R));
|
|
1555
1555
|
}
|
|
1556
1556
|
if (t.length > 0) {
|
|
1557
1557
|
const N = O.topologicalSort(t);
|
|
1558
1558
|
for (const r of N) {
|
|
1559
|
-
const [n,
|
|
1559
|
+
const [n, C] = r.split("."), i = e.get(n), a = i.measures[C];
|
|
1560
1560
|
S.set(r, () => this.buildCalculatedMeasure(
|
|
1561
|
-
|
|
1561
|
+
a,
|
|
1562
1562
|
i,
|
|
1563
1563
|
e,
|
|
1564
1564
|
S,
|
|
@@ -1580,7 +1580,7 @@ class ge {
|
|
|
1580
1580
|
const [t, s] = I.split("."), O = S.get(t);
|
|
1581
1581
|
if (O && O.dimensions && O.dimensions[s]) {
|
|
1582
1582
|
const N = O.dimensions[s], r = w(N.sql, R);
|
|
1583
|
-
A[I] =
|
|
1583
|
+
A[I] = L`${r}`.as(I);
|
|
1584
1584
|
}
|
|
1585
1585
|
}
|
|
1586
1586
|
if (e.measures) {
|
|
@@ -1593,7 +1593,7 @@ class ge {
|
|
|
1593
1593
|
const s = I.get(t);
|
|
1594
1594
|
if (s) {
|
|
1595
1595
|
const O = s();
|
|
1596
|
-
A[t] =
|
|
1596
|
+
A[t] = L`${O}`.as(t);
|
|
1597
1597
|
}
|
|
1598
1598
|
}
|
|
1599
1599
|
}
|
|
@@ -1606,7 +1606,7 @@ class ge {
|
|
|
1606
1606
|
I.granularity,
|
|
1607
1607
|
R
|
|
1608
1608
|
);
|
|
1609
|
-
A[I.dimension] =
|
|
1609
|
+
A[I.dimension] = L`${r}`.as(I.dimension);
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
1612
|
return Object.keys(A).length === 0 && (A.count = lE()), A;
|
|
@@ -1646,34 +1646,34 @@ class ge {
|
|
|
1646
1646
|
throw new Error(
|
|
1647
1647
|
`Calculated measure '${e.name}.${E.name || "unknown"}' missing calculatedSql property`
|
|
1648
1648
|
);
|
|
1649
|
-
const I = /* @__PURE__ */ new Map(), t =
|
|
1649
|
+
const I = /* @__PURE__ */ new Map(), t = GE(E.calculatedSql, e.name);
|
|
1650
1650
|
for (const s of t) {
|
|
1651
1651
|
const [O, N] = s.split("."), r = A.get(O);
|
|
1652
1652
|
if (r && r.measures[N]) {
|
|
1653
1653
|
const n = r.measures[N];
|
|
1654
1654
|
if (R.measures.includes(s)) {
|
|
1655
|
-
const
|
|
1655
|
+
const C = L`${L.identifier(R.cteAlias)}.${L.identifier(N)}`;
|
|
1656
1656
|
let i;
|
|
1657
1657
|
switch (n.type) {
|
|
1658
1658
|
case "count":
|
|
1659
1659
|
case "countDistinct":
|
|
1660
1660
|
case "sum":
|
|
1661
|
-
i = g(
|
|
1661
|
+
i = g(C);
|
|
1662
1662
|
break;
|
|
1663
1663
|
case "avg":
|
|
1664
|
-
i = this.databaseAdapter.buildAvg(
|
|
1664
|
+
i = this.databaseAdapter.buildAvg(C);
|
|
1665
1665
|
break;
|
|
1666
1666
|
case "min":
|
|
1667
|
-
i = SE(
|
|
1667
|
+
i = SE(C);
|
|
1668
1668
|
break;
|
|
1669
1669
|
case "max":
|
|
1670
|
-
i = AE(
|
|
1670
|
+
i = AE(C);
|
|
1671
1671
|
break;
|
|
1672
1672
|
case "number":
|
|
1673
|
-
i = g(
|
|
1673
|
+
i = g(C);
|
|
1674
1674
|
break;
|
|
1675
1675
|
default:
|
|
1676
|
-
i = g(
|
|
1676
|
+
i = g(C);
|
|
1677
1677
|
}
|
|
1678
1678
|
I.set(s, () => i);
|
|
1679
1679
|
}
|
|
@@ -1710,7 +1710,7 @@ class ge {
|
|
|
1710
1710
|
A
|
|
1711
1711
|
);
|
|
1712
1712
|
} else {
|
|
1713
|
-
const t =
|
|
1713
|
+
const t = L`${L.identifier(I.cteAlias)}.${L.identifier(e)}`;
|
|
1714
1714
|
switch (R.type) {
|
|
1715
1715
|
case "count":
|
|
1716
1716
|
case "countDistinct":
|
|
@@ -1748,7 +1748,7 @@ class ge {
|
|
|
1748
1748
|
if (E.filters && E.filters.length > 0) {
|
|
1749
1749
|
const A = E.filters.map((S) => {
|
|
1750
1750
|
const I = S(e);
|
|
1751
|
-
return I ?
|
|
1751
|
+
return I ? L`(${I})` : void 0;
|
|
1752
1752
|
}).filter(Boolean);
|
|
1753
1753
|
if (A.length > 0) {
|
|
1754
1754
|
const S = A.length === 1 ? A[0] : V(...A);
|
|
@@ -1761,7 +1761,7 @@ class ge {
|
|
|
1761
1761
|
case "count":
|
|
1762
1762
|
return lE(R);
|
|
1763
1763
|
case "countDistinct":
|
|
1764
|
-
return
|
|
1764
|
+
return de(R);
|
|
1765
1765
|
case "sum":
|
|
1766
1766
|
return g(R);
|
|
1767
1767
|
case "avg":
|
|
@@ -1781,7 +1781,7 @@ class ge {
|
|
|
1781
1781
|
*/
|
|
1782
1782
|
buildTimeDimensionExpression(E, e, R) {
|
|
1783
1783
|
const A = w(E, R);
|
|
1784
|
-
return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof d ? A :
|
|
1784
|
+
return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof d ? A : L`${A}`;
|
|
1785
1785
|
}
|
|
1786
1786
|
/**
|
|
1787
1787
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -1798,10 +1798,10 @@ class ge {
|
|
|
1798
1798
|
for (const t of e.timeDimensions) {
|
|
1799
1799
|
const [s, O] = t.dimension.split("."), N = I.get(s);
|
|
1800
1800
|
if (N && N.dimensions[O] && t.dateRange) {
|
|
1801
|
-
if (A?.preAggregationCTEs && A.preAggregationCTEs.some((
|
|
1801
|
+
if (A?.preAggregationCTEs && A.preAggregationCTEs.some((a) => a.cube.name === s))
|
|
1802
1802
|
continue;
|
|
1803
|
-
const r = N.dimensions[O], n = w(r.sql, R),
|
|
1804
|
-
|
|
1803
|
+
const r = N.dimensions[O], n = w(r.sql, R), C = this.buildDateRangeCondition(n, t.dateRange);
|
|
1804
|
+
C && S.push(C);
|
|
1805
1805
|
}
|
|
1806
1806
|
}
|
|
1807
1807
|
return S;
|
|
@@ -1825,13 +1825,13 @@ class ge {
|
|
|
1825
1825
|
*/
|
|
1826
1826
|
processFilter(E, e, R, A, S) {
|
|
1827
1827
|
if ("and" in E || "or" in E) {
|
|
1828
|
-
const
|
|
1829
|
-
if (
|
|
1830
|
-
const i =
|
|
1828
|
+
const C = E;
|
|
1829
|
+
if (C.and) {
|
|
1830
|
+
const i = C.and.map((a) => this.processFilter(a, e, R, A, S)).filter((a) => a !== null);
|
|
1831
1831
|
return i.length > 0 ? V(...i) : null;
|
|
1832
1832
|
}
|
|
1833
|
-
if (
|
|
1834
|
-
const i =
|
|
1833
|
+
if (C.or) {
|
|
1834
|
+
const i = C.or.map((a) => this.processFilter(a, e, R, A, S)).filter((a) => a !== null);
|
|
1835
1835
|
return i.length > 0 ? PE(...i) : null;
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
@@ -1854,9 +1854,9 @@ class ge {
|
|
|
1854
1854
|
if (A === "where" && r)
|
|
1855
1855
|
return null;
|
|
1856
1856
|
if (A === "having" && r) {
|
|
1857
|
-
const
|
|
1857
|
+
const C = this.buildHavingMeasureExpression(t, s, r, R, S);
|
|
1858
1858
|
return this.buildFilterCondition(
|
|
1859
|
-
|
|
1859
|
+
C,
|
|
1860
1860
|
I.operator,
|
|
1861
1861
|
I.values,
|
|
1862
1862
|
n,
|
|
@@ -1901,7 +1901,7 @@ class ge {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
1903
1903
|
case "notEquals":
|
|
1904
|
-
return I.length > 1 ?
|
|
1904
|
+
return I.length > 1 ? OT(E, I) : I.length === 1 ? IT(E, t) : null;
|
|
1905
1905
|
case "contains":
|
|
1906
1906
|
return this.databaseAdapter.buildStringCondition(E, "contains", t);
|
|
1907
1907
|
case "notContains":
|
|
@@ -1919,9 +1919,9 @@ class ge {
|
|
|
1919
1919
|
case "lte":
|
|
1920
1920
|
return Z(E, t);
|
|
1921
1921
|
case "set":
|
|
1922
|
-
return
|
|
1922
|
+
return sT(E);
|
|
1923
1923
|
case "notSet":
|
|
1924
|
-
return
|
|
1924
|
+
return tT(E);
|
|
1925
1925
|
case "inDateRange":
|
|
1926
1926
|
if (I.length >= 2) {
|
|
1927
1927
|
const s = this.normalizeDate(I[0]);
|
|
@@ -1960,7 +1960,7 @@ class ge {
|
|
|
1960
1960
|
case "in":
|
|
1961
1961
|
return I.length > 0 ? cE(E, I) : null;
|
|
1962
1962
|
case "notIn":
|
|
1963
|
-
return I.length > 0 ?
|
|
1963
|
+
return I.length > 0 ? OT(E, I) : null;
|
|
1964
1964
|
case "like":
|
|
1965
1965
|
return this.databaseAdapter.buildStringCondition(E, "like", t);
|
|
1966
1966
|
case "notLike":
|
|
@@ -1973,22 +1973,22 @@ class ge {
|
|
|
1973
1973
|
return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
|
|
1974
1974
|
case "isEmpty":
|
|
1975
1975
|
return PE(
|
|
1976
|
-
|
|
1976
|
+
tT(E),
|
|
1977
1977
|
k(E, "")
|
|
1978
1978
|
);
|
|
1979
1979
|
case "isNotEmpty":
|
|
1980
1980
|
return V(
|
|
1981
|
-
|
|
1982
|
-
|
|
1981
|
+
sT(E),
|
|
1982
|
+
IT(E, "")
|
|
1983
1983
|
);
|
|
1984
1984
|
// PostgreSQL array operators - silent no-op for other databases
|
|
1985
1985
|
// These use Drizzle's built-in array operator functions
|
|
1986
1986
|
case "arrayContains":
|
|
1987
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
1987
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? le(E, I) : null;
|
|
1988
1988
|
case "arrayOverlaps":
|
|
1989
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
1989
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? Ge(E, I) : null;
|
|
1990
1990
|
case "arrayContained":
|
|
1991
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
1991
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? ue(E, I) : null;
|
|
1992
1992
|
default:
|
|
1993
1993
|
return null;
|
|
1994
1994
|
}
|
|
@@ -2043,78 +2043,78 @@ class ge {
|
|
|
2043
2043
|
if (R === "today") {
|
|
2044
2044
|
const n = new Date(e);
|
|
2045
2045
|
n.setUTCHours(0, 0, 0, 0);
|
|
2046
|
-
const
|
|
2047
|
-
return
|
|
2046
|
+
const C = new Date(e);
|
|
2047
|
+
return C.setUTCHours(23, 59, 59, 999), { start: n, end: C };
|
|
2048
2048
|
}
|
|
2049
2049
|
if (R === "yesterday") {
|
|
2050
2050
|
const n = new Date(e);
|
|
2051
2051
|
n.setUTCDate(I - 1), n.setUTCHours(0, 0, 0, 0);
|
|
2052
|
-
const
|
|
2053
|
-
return
|
|
2052
|
+
const C = new Date(e);
|
|
2053
|
+
return C.setUTCDate(I - 1), C.setUTCHours(23, 59, 59, 999), { start: n, end: C };
|
|
2054
2054
|
}
|
|
2055
2055
|
if (R === "this week") {
|
|
2056
|
-
const n = t === 0 ? -6 : 1 - t,
|
|
2057
|
-
|
|
2058
|
-
const i = new Date(
|
|
2059
|
-
return i.setUTCDate(
|
|
2056
|
+
const n = t === 0 ? -6 : 1 - t, C = new Date(e);
|
|
2057
|
+
C.setUTCDate(I + n), C.setUTCHours(0, 0, 0, 0);
|
|
2058
|
+
const i = new Date(C);
|
|
2059
|
+
return i.setUTCDate(C.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
2060
2060
|
}
|
|
2061
2061
|
if (R === "this month") {
|
|
2062
|
-
const n = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)),
|
|
2063
|
-
return { start: n, end:
|
|
2062
|
+
const n = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(A, S + 1, 0, 23, 59, 59, 999));
|
|
2063
|
+
return { start: n, end: C };
|
|
2064
2064
|
}
|
|
2065
2065
|
if (R === "this quarter") {
|
|
2066
|
-
const n = Math.floor(S / 3),
|
|
2067
|
-
return { start:
|
|
2066
|
+
const n = Math.floor(S / 3), C = new Date(Date.UTC(A, n * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(A, n * 3 + 3, 0, 23, 59, 59, 999));
|
|
2067
|
+
return { start: C, end: i };
|
|
2068
2068
|
}
|
|
2069
2069
|
if (R === "this year") {
|
|
2070
|
-
const n = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)),
|
|
2071
|
-
return { start: n, end:
|
|
2070
|
+
const n = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(A, 11, 31, 23, 59, 59, 999));
|
|
2071
|
+
return { start: n, end: C };
|
|
2072
2072
|
}
|
|
2073
2073
|
const s = R.match(/^last\s+(\d+)\s+days?$/);
|
|
2074
2074
|
if (s) {
|
|
2075
|
-
const n = parseInt(s[1], 10),
|
|
2076
|
-
|
|
2075
|
+
const n = parseInt(s[1], 10), C = new Date(e);
|
|
2076
|
+
C.setUTCDate(I - n + 1), C.setUTCHours(0, 0, 0, 0);
|
|
2077
2077
|
const i = new Date(e);
|
|
2078
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
2078
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
2079
2079
|
}
|
|
2080
2080
|
const O = R.match(/^last\s+(\d+)\s+weeks?$/);
|
|
2081
2081
|
if (O) {
|
|
2082
|
-
const
|
|
2083
|
-
i.setUTCDate(I -
|
|
2084
|
-
const
|
|
2085
|
-
return
|
|
2082
|
+
const C = parseInt(O[1], 10) * 7, i = new Date(e);
|
|
2083
|
+
i.setUTCDate(I - C + 1), i.setUTCHours(0, 0, 0, 0);
|
|
2084
|
+
const a = new Date(e);
|
|
2085
|
+
return a.setUTCHours(23, 59, 59, 999), { start: i, end: a };
|
|
2086
2086
|
}
|
|
2087
2087
|
if (R === "last week") {
|
|
2088
|
-
const n = t === 0 ? -13 : -6 - t,
|
|
2089
|
-
|
|
2090
|
-
const i = new Date(
|
|
2091
|
-
return i.setUTCDate(
|
|
2088
|
+
const n = t === 0 ? -13 : -6 - t, C = new Date(e);
|
|
2089
|
+
C.setUTCDate(I + n), C.setUTCHours(0, 0, 0, 0);
|
|
2090
|
+
const i = new Date(C);
|
|
2091
|
+
return i.setUTCDate(C.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
2092
2092
|
}
|
|
2093
2093
|
if (R === "last month") {
|
|
2094
|
-
const n = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)),
|
|
2095
|
-
return { start: n, end:
|
|
2094
|
+
const n = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(A, S, 0, 23, 59, 59, 999));
|
|
2095
|
+
return { start: n, end: C };
|
|
2096
2096
|
}
|
|
2097
2097
|
if (R === "last quarter") {
|
|
2098
|
-
const n = Math.floor(S / 3),
|
|
2099
|
-
return { start:
|
|
2098
|
+
const n = Math.floor(S / 3), C = n === 0 ? 3 : n - 1, i = n === 0 ? A - 1 : A, a = new Date(Date.UTC(i, C * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, C * 3 + 3, 0, 23, 59, 59, 999));
|
|
2099
|
+
return { start: a, end: l };
|
|
2100
2100
|
}
|
|
2101
2101
|
if (R === "last year") {
|
|
2102
|
-
const n = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)),
|
|
2103
|
-
return { start: n, end:
|
|
2102
|
+
const n = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(A - 1, 11, 31, 23, 59, 59, 999));
|
|
2103
|
+
return { start: n, end: C };
|
|
2104
2104
|
}
|
|
2105
2105
|
if (R === "last 12 months") {
|
|
2106
|
-
const n = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)),
|
|
2107
|
-
return
|
|
2106
|
+
const n = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)), C = new Date(e);
|
|
2107
|
+
return C.setUTCHours(23, 59, 59, 999), { start: n, end: C };
|
|
2108
2108
|
}
|
|
2109
2109
|
const N = R.match(/^last\s+(\d+)\s+months?$/);
|
|
2110
2110
|
if (N) {
|
|
2111
|
-
const n = parseInt(N[1], 10),
|
|
2112
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
2111
|
+
const n = parseInt(N[1], 10), C = new Date(Date.UTC(A, S - n + 1, 1, 0, 0, 0, 0)), i = new Date(e);
|
|
2112
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
2113
2113
|
}
|
|
2114
2114
|
const r = R.match(/^last\s+(\d+)\s+years?$/);
|
|
2115
2115
|
if (r) {
|
|
2116
|
-
const n = parseInt(r[1], 10),
|
|
2117
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
2116
|
+
const n = parseInt(r[1], 10), C = new Date(Date.UTC(A - n, 0, 1, 0, 0, 0, 0)), i = new Date(e);
|
|
2117
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
2118
2118
|
}
|
|
2119
2119
|
return null;
|
|
2120
2120
|
}
|
|
@@ -2155,16 +2155,16 @@ class ge {
|
|
|
2155
2155
|
for (const s of e.dimensions) {
|
|
2156
2156
|
const [O, N] = s.split("."), r = t.get(O);
|
|
2157
2157
|
if (r && r.dimensions && r.dimensions[N])
|
|
2158
|
-
if (A?.preAggregationCTEs?.some((
|
|
2159
|
-
const
|
|
2158
|
+
if (A?.preAggregationCTEs?.some((C) => C.cube.name === O)) {
|
|
2159
|
+
const C = A.preAggregationCTEs.find((a) => a.cube.name === O), i = C.joinKeys.find((a) => a.targetColumn === N);
|
|
2160
2160
|
if (i && i.sourceColumnObj)
|
|
2161
2161
|
S.push(i.sourceColumnObj);
|
|
2162
2162
|
else {
|
|
2163
|
-
const
|
|
2164
|
-
S.push(
|
|
2163
|
+
const a = L`${L.identifier(C.cteAlias)}.${L.identifier(N)}`;
|
|
2164
|
+
S.push(a);
|
|
2165
2165
|
}
|
|
2166
2166
|
} else {
|
|
2167
|
-
const
|
|
2167
|
+
const C = r.dimensions[N], i = w(C.sql, R);
|
|
2168
2168
|
S.push(i);
|
|
2169
2169
|
}
|
|
2170
2170
|
}
|
|
@@ -2172,22 +2172,22 @@ class ge {
|
|
|
2172
2172
|
for (const s of e.timeDimensions) {
|
|
2173
2173
|
const [O, N] = s.dimension.split("."), r = t.get(O);
|
|
2174
2174
|
if (r && r.dimensions && r.dimensions[N])
|
|
2175
|
-
if (A?.preAggregationCTEs?.some((
|
|
2176
|
-
const
|
|
2175
|
+
if (A?.preAggregationCTEs?.some((C) => C.cube.name === O)) {
|
|
2176
|
+
const C = A.preAggregationCTEs.find((a) => a.cube.name === O), i = C.joinKeys.find((a) => a.targetColumn === N);
|
|
2177
2177
|
if (i && i.sourceColumnObj) {
|
|
2178
|
-
const
|
|
2178
|
+
const a = this.buildTimeDimensionExpression(
|
|
2179
2179
|
i.sourceColumnObj,
|
|
2180
2180
|
s.granularity,
|
|
2181
2181
|
R
|
|
2182
2182
|
);
|
|
2183
|
-
S.push(
|
|
2183
|
+
S.push(a);
|
|
2184
2184
|
} else {
|
|
2185
|
-
const
|
|
2186
|
-
S.push(
|
|
2185
|
+
const a = L`${L.identifier(C.cteAlias)}.${L.identifier(N)}`;
|
|
2186
|
+
S.push(a);
|
|
2187
2187
|
}
|
|
2188
2188
|
} else {
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2189
|
+
const C = r.dimensions[N], i = this.buildTimeDimensionExpression(
|
|
2190
|
+
C.sql,
|
|
2191
2191
|
s.granularity,
|
|
2192
2192
|
R
|
|
2193
2193
|
);
|
|
@@ -2209,7 +2209,7 @@ class ge {
|
|
|
2209
2209
|
for (const [S, I] of Object.entries(E.order)) {
|
|
2210
2210
|
if (!A.includes(S))
|
|
2211
2211
|
throw new Error(`Cannot order by '${S}': field is not selected in the query`);
|
|
2212
|
-
const t = I === "desc" ?
|
|
2212
|
+
const t = I === "desc" ? me(L.identifier(S)) : rT(L.identifier(S));
|
|
2213
2213
|
R.push(t);
|
|
2214
2214
|
}
|
|
2215
2215
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
@@ -2217,7 +2217,7 @@ class ge {
|
|
|
2217
2217
|
(t, s) => t.dimension.localeCompare(s.dimension)
|
|
2218
2218
|
);
|
|
2219
2219
|
for (const t of I)
|
|
2220
|
-
S.has(t.dimension) || R.push(
|
|
2220
|
+
S.has(t.dimension) || R.push(rT(L.identifier(t.dimension)));
|
|
2221
2221
|
}
|
|
2222
2222
|
return R;
|
|
2223
2223
|
}
|
|
@@ -2258,7 +2258,7 @@ class ge {
|
|
|
2258
2258
|
return A;
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
class
|
|
2261
|
+
class Te {
|
|
2262
2262
|
/**
|
|
2263
2263
|
* Analyze a semantic query to determine which cubes are involved
|
|
2264
2264
|
*/
|
|
@@ -2421,35 +2421,35 @@ class Ke {
|
|
|
2421
2421
|
if (!n)
|
|
2422
2422
|
throw new Error(`Cube '${N}' not found`);
|
|
2423
2423
|
if (r.relationship === "belongsToMany" && r.through) {
|
|
2424
|
-
const
|
|
2424
|
+
const C = ye(r, A.securityContext);
|
|
2425
2425
|
S.push({
|
|
2426
2426
|
cube: n,
|
|
2427
2427
|
alias: `${N.toLowerCase()}_cube`,
|
|
2428
|
-
joinType:
|
|
2428
|
+
joinType: C.junctionJoins[1].joinType,
|
|
2429
2429
|
// Use the target join type
|
|
2430
|
-
joinCondition:
|
|
2430
|
+
joinCondition: C.junctionJoins[1].condition,
|
|
2431
2431
|
// Target join condition
|
|
2432
2432
|
junctionTable: {
|
|
2433
2433
|
table: r.through.table,
|
|
2434
2434
|
alias: `junction_${N.toLowerCase()}`,
|
|
2435
|
-
joinType:
|
|
2436
|
-
joinCondition:
|
|
2435
|
+
joinType: C.junctionJoins[0].joinType,
|
|
2436
|
+
joinCondition: C.junctionJoins[0].condition,
|
|
2437
2437
|
securitySql: r.through.securitySql
|
|
2438
2438
|
}
|
|
2439
2439
|
});
|
|
2440
2440
|
} else {
|
|
2441
|
-
const
|
|
2441
|
+
const C = this.buildJoinCondition(
|
|
2442
2442
|
r,
|
|
2443
2443
|
null,
|
|
2444
2444
|
// No source alias needed - use the actual column
|
|
2445
2445
|
null
|
|
2446
2446
|
// No target alias needed - use the actual column
|
|
2447
|
-
), i =
|
|
2447
|
+
), i = jE(r.relationship, r.sqlJoinType);
|
|
2448
2448
|
S.push({
|
|
2449
2449
|
cube: n,
|
|
2450
2450
|
alias: `${N.toLowerCase()}_cube`,
|
|
2451
2451
|
joinType: i,
|
|
2452
|
-
joinCondition:
|
|
2452
|
+
joinCondition: C
|
|
2453
2453
|
});
|
|
2454
2454
|
}
|
|
2455
2455
|
I.add(N);
|
|
@@ -2463,7 +2463,7 @@ class Ke {
|
|
|
2463
2463
|
buildJoinCondition(E, e, R) {
|
|
2464
2464
|
const A = [];
|
|
2465
2465
|
for (const S of E.on) {
|
|
2466
|
-
const I = e ?
|
|
2466
|
+
const I = e ? L`${L.identifier(e)}.${L.identifier(S.source.name)}` : S.source, t = R ? L`${L.identifier(R)}.${L.identifier(S.target.name)}` : S.target, s = S.as || k;
|
|
2467
2467
|
A.push(s(I, t));
|
|
2468
2468
|
}
|
|
2469
2469
|
return V(...A);
|
|
@@ -2482,17 +2482,17 @@ class Ke {
|
|
|
2482
2482
|
const { cube: t, path: s } = S.shift(), O = E.get(t);
|
|
2483
2483
|
if (O?.joins)
|
|
2484
2484
|
for (const [, N] of Object.entries(O.joins)) {
|
|
2485
|
-
const n =
|
|
2485
|
+
const n = uE(N.targetCube).name;
|
|
2486
2486
|
if (I.has(n))
|
|
2487
2487
|
continue;
|
|
2488
|
-
const
|
|
2488
|
+
const C = [...s, {
|
|
2489
2489
|
fromCube: t,
|
|
2490
2490
|
toCube: n,
|
|
2491
2491
|
joinDef: N
|
|
2492
2492
|
}];
|
|
2493
2493
|
if (n === R)
|
|
2494
|
-
return
|
|
2495
|
-
I.add(n), S.push({ cube: n, path:
|
|
2494
|
+
return C;
|
|
2495
|
+
I.add(n), S.push({ cube: n, path: C });
|
|
2496
2496
|
}
|
|
2497
2497
|
}
|
|
2498
2498
|
return null;
|
|
@@ -2511,18 +2511,18 @@ class Ke {
|
|
|
2511
2511
|
if (!t)
|
|
2512
2512
|
continue;
|
|
2513
2513
|
const s = A.measures ? A.measures.filter(
|
|
2514
|
-
(
|
|
2514
|
+
(C) => C.startsWith(I.cube.name + ".")
|
|
2515
2515
|
) : [], O = this.extractMeasuresFromFilters(A, I.cube.name), N = [.../* @__PURE__ */ new Set([...s, ...O])];
|
|
2516
2516
|
if (N.length === 0)
|
|
2517
2517
|
continue;
|
|
2518
2518
|
const r = this.expandCalculatedMeasureDependencies(
|
|
2519
2519
|
I.cube,
|
|
2520
2520
|
N
|
|
2521
|
-
), n = t.on.map((
|
|
2522
|
-
sourceColumn:
|
|
2523
|
-
targetColumn:
|
|
2524
|
-
sourceColumnObj:
|
|
2525
|
-
targetColumnObj:
|
|
2521
|
+
), n = t.on.map((C) => ({
|
|
2522
|
+
sourceColumn: C.source.name,
|
|
2523
|
+
targetColumn: C.target.name,
|
|
2524
|
+
sourceColumnObj: C.source,
|
|
2525
|
+
targetColumnObj: C.target
|
|
2526
2526
|
}));
|
|
2527
2527
|
S.push({
|
|
2528
2528
|
cube: I.cube,
|
|
@@ -2574,20 +2574,225 @@ class Ke {
|
|
|
2574
2574
|
if (!E.joins)
|
|
2575
2575
|
return null;
|
|
2576
2576
|
for (const [, R] of Object.entries(E.joins))
|
|
2577
|
-
if (
|
|
2577
|
+
if (uE(R.targetCube).name === e && R.relationship === "hasMany")
|
|
2578
2578
|
return R;
|
|
2579
2579
|
return null;
|
|
2580
2580
|
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Analyze query planning decisions without building the full query
|
|
2583
|
+
* Returns detailed metadata about how the query plan would be constructed
|
|
2584
|
+
* Used for debugging and transparency in the playground UI
|
|
2585
|
+
*/
|
|
2586
|
+
analyzeQueryPlan(E, e, R) {
|
|
2587
|
+
const A = this.analyzeCubeUsage(e), S = Array.from(A);
|
|
2588
|
+
if (S.length === 0)
|
|
2589
|
+
return {
|
|
2590
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2591
|
+
cubeCount: 0,
|
|
2592
|
+
cubesInvolved: [],
|
|
2593
|
+
primaryCube: {
|
|
2594
|
+
selectedCube: "",
|
|
2595
|
+
reason: "single_cube",
|
|
2596
|
+
explanation: "No cubes found in query"
|
|
2597
|
+
},
|
|
2598
|
+
joinPaths: [],
|
|
2599
|
+
preAggregations: [],
|
|
2600
|
+
querySummary: {
|
|
2601
|
+
queryType: "single_cube",
|
|
2602
|
+
joinCount: 0,
|
|
2603
|
+
cteCount: 0,
|
|
2604
|
+
hasPreAggregation: !1
|
|
2605
|
+
},
|
|
2606
|
+
warnings: ["No cubes found in query - add measures or dimensions"]
|
|
2607
|
+
};
|
|
2608
|
+
const I = this.analyzePrimaryCubeSelection(S, e, E), t = I.selectedCube, s = {
|
|
2609
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2610
|
+
cubeCount: S.length,
|
|
2611
|
+
cubesInvolved: S.sort(),
|
|
2612
|
+
primaryCube: I,
|
|
2613
|
+
joinPaths: [],
|
|
2614
|
+
preAggregations: [],
|
|
2615
|
+
querySummary: {
|
|
2616
|
+
queryType: "single_cube",
|
|
2617
|
+
joinCount: 0,
|
|
2618
|
+
cteCount: 0,
|
|
2619
|
+
hasPreAggregation: !1
|
|
2620
|
+
},
|
|
2621
|
+
warnings: []
|
|
2622
|
+
};
|
|
2623
|
+
if (S.length > 1) {
|
|
2624
|
+
const O = S.filter((C) => C !== t);
|
|
2625
|
+
for (const C of O)
|
|
2626
|
+
s.joinPaths.push(
|
|
2627
|
+
this.analyzeJoinPath(E, t, C)
|
|
2628
|
+
);
|
|
2629
|
+
const N = E.get(t);
|
|
2630
|
+
N && (s.preAggregations = this.analyzePreAggregations(
|
|
2631
|
+
E,
|
|
2632
|
+
N,
|
|
2633
|
+
O,
|
|
2634
|
+
e
|
|
2635
|
+
));
|
|
2636
|
+
const r = s.joinPaths.filter((C) => C.pathFound), n = s.joinPaths.filter((C) => !C.pathFound);
|
|
2637
|
+
s.querySummary.joinCount = r.length, s.querySummary.cteCount = s.preAggregations.length, s.querySummary.hasPreAggregation = s.preAggregations.length > 0, s.preAggregations.length > 0 ? s.querySummary.queryType = "multi_cube_cte" : s.querySummary.queryType = "multi_cube_join";
|
|
2638
|
+
for (const C of n)
|
|
2639
|
+
s.warnings.push(
|
|
2640
|
+
`No join path found to cube '${C.targetCube}'. Check that joins are defined correctly.`
|
|
2641
|
+
);
|
|
2642
|
+
}
|
|
2643
|
+
return s;
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* Analyze why a particular cube was chosen as primary
|
|
2647
|
+
*/
|
|
2648
|
+
analyzePrimaryCubeSelection(E, e, R) {
|
|
2649
|
+
if (E.length === 1)
|
|
2650
|
+
return {
|
|
2651
|
+
selectedCube: E[0],
|
|
2652
|
+
reason: "single_cube",
|
|
2653
|
+
explanation: "Only one cube is used in this query"
|
|
2654
|
+
};
|
|
2655
|
+
const A = [], S = (e.dimensions || []).map((O) => O.split(".")[0]), I = /* @__PURE__ */ new Map();
|
|
2656
|
+
for (const O of S)
|
|
2657
|
+
I.set(O, (I.get(O) || 0) + 1);
|
|
2658
|
+
for (const O of E) {
|
|
2659
|
+
const N = R.get(O), r = I.get(O) || 0, n = N?.joins ? Object.keys(N.joins).length : 0, C = this.canReachAllCubes(O, E, R);
|
|
2660
|
+
A.push({
|
|
2661
|
+
cubeName: O,
|
|
2662
|
+
dimensionCount: r,
|
|
2663
|
+
joinCount: n,
|
|
2664
|
+
canReachAll: C
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
if (e.dimensions && e.dimensions.length > 0) {
|
|
2668
|
+
const O = Math.max(...A.map((N) => N.dimensionCount));
|
|
2669
|
+
if (O > 0) {
|
|
2670
|
+
const N = A.filter((r) => r.dimensionCount === O).sort((r, n) => r.cubeName.localeCompare(n.cubeName));
|
|
2671
|
+
for (const r of N)
|
|
2672
|
+
if (r.canReachAll)
|
|
2673
|
+
return {
|
|
2674
|
+
selectedCube: r.cubeName,
|
|
2675
|
+
reason: "most_dimensions",
|
|
2676
|
+
explanation: `Selected because it has ${r.dimensionCount} dimension${r.dimensionCount !== 1 ? "s" : ""} in the query (defines the analytical grain)`,
|
|
2677
|
+
candidates: A
|
|
2678
|
+
};
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
const t = A.filter((O) => O.canReachAll);
|
|
2682
|
+
if (t.length > 0) {
|
|
2683
|
+
const O = Math.max(...t.map((r) => r.joinCount)), N = t.filter((r) => r.joinCount === O).sort((r, n) => r.cubeName.localeCompare(n.cubeName))[0];
|
|
2684
|
+
return {
|
|
2685
|
+
selectedCube: N.cubeName,
|
|
2686
|
+
reason: "most_connected",
|
|
2687
|
+
explanation: `Selected because it has ${N.joinCount} join relationship${N.joinCount !== 1 ? "s" : ""} and can reach all other cubes`,
|
|
2688
|
+
candidates: A
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
return {
|
|
2692
|
+
selectedCube: [...E].sort()[0],
|
|
2693
|
+
reason: "alphabetical_fallback",
|
|
2694
|
+
explanation: "Selected alphabetically as fallback (no cube could reach all others)",
|
|
2695
|
+
candidates: A
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
/**
|
|
2699
|
+
* Analyze the join path between two cubes with detailed step information
|
|
2700
|
+
*/
|
|
2701
|
+
analyzeJoinPath(E, e, R) {
|
|
2702
|
+
const A = [e], S = [{ cube: e, path: [] }], I = /* @__PURE__ */ new Set([e]);
|
|
2703
|
+
for (; S.length > 0; ) {
|
|
2704
|
+
const { cube: t, path: s } = S.shift(), O = E.get(t);
|
|
2705
|
+
if (O?.joins)
|
|
2706
|
+
for (const [, N] of Object.entries(O.joins)) {
|
|
2707
|
+
const n = uE(N.targetCube).name;
|
|
2708
|
+
if (I.has(n))
|
|
2709
|
+
continue;
|
|
2710
|
+
A.push(n), I.add(n);
|
|
2711
|
+
const C = [...s, {
|
|
2712
|
+
fromCube: t,
|
|
2713
|
+
toCube: n,
|
|
2714
|
+
joinDef: N
|
|
2715
|
+
}];
|
|
2716
|
+
if (n === R) {
|
|
2717
|
+
const i = C.map((a) => {
|
|
2718
|
+
const l = jE(a.joinDef.relationship, a.joinDef.sqlJoinType), P = a.joinDef.on.map((M) => ({
|
|
2719
|
+
sourceColumn: M.source.name,
|
|
2720
|
+
targetColumn: M.target.name
|
|
2721
|
+
})), U = {
|
|
2722
|
+
fromCube: a.fromCube,
|
|
2723
|
+
toCube: a.toCube,
|
|
2724
|
+
relationship: a.joinDef.relationship,
|
|
2725
|
+
joinType: l,
|
|
2726
|
+
joinColumns: P
|
|
2727
|
+
};
|
|
2728
|
+
if (a.joinDef.relationship === "belongsToMany" && a.joinDef.through) {
|
|
2729
|
+
const M = a.joinDef.through;
|
|
2730
|
+
U.junctionTable = {
|
|
2731
|
+
tableName: M.table[/* @__PURE__ */ Symbol.for("drizzle:Name")] || "junction_table",
|
|
2732
|
+
sourceColumns: M.sourceKey.map((G) => G.target.name),
|
|
2733
|
+
targetColumns: M.targetKey.map((G) => G.source.name)
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2736
|
+
return U;
|
|
2737
|
+
});
|
|
2738
|
+
return {
|
|
2739
|
+
targetCube: R,
|
|
2740
|
+
pathFound: !0,
|
|
2741
|
+
path: i,
|
|
2742
|
+
pathLength: i.length,
|
|
2743
|
+
visitedCubes: A
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
S.push({ cube: n, path: C });
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
return {
|
|
2750
|
+
targetCube: R,
|
|
2751
|
+
pathFound: !1,
|
|
2752
|
+
error: `No join path found from '${e}' to '${R}'. Ensure the target cube has a relationship defined (belongsTo, hasOne, hasMany, or belongsToMany).`,
|
|
2753
|
+
visitedCubes: A
|
|
2754
|
+
};
|
|
2755
|
+
}
|
|
2756
|
+
/**
|
|
2757
|
+
* Analyze pre-aggregation requirements for hasMany relationships
|
|
2758
|
+
*/
|
|
2759
|
+
analyzePreAggregations(E, e, R, A) {
|
|
2760
|
+
const S = [];
|
|
2761
|
+
if (!A.measures || A.measures.length === 0)
|
|
2762
|
+
return S;
|
|
2763
|
+
for (const I of R) {
|
|
2764
|
+
const t = this.findHasManyJoinDef(e, I);
|
|
2765
|
+
if (!t)
|
|
2766
|
+
continue;
|
|
2767
|
+
const s = A.measures.filter(
|
|
2768
|
+
(N) => N.startsWith(I + ".")
|
|
2769
|
+
);
|
|
2770
|
+
if (s.length === 0)
|
|
2771
|
+
continue;
|
|
2772
|
+
const O = t.on.map((N) => ({
|
|
2773
|
+
sourceColumn: N.source.name,
|
|
2774
|
+
targetColumn: N.target.name
|
|
2775
|
+
}));
|
|
2776
|
+
S.push({
|
|
2777
|
+
cubeName: I,
|
|
2778
|
+
cteAlias: `${I.toLowerCase()}_agg`,
|
|
2779
|
+
reason: `hasMany relationship from ${e.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
|
|
2780
|
+
measures: s,
|
|
2781
|
+
joinKeys: O
|
|
2782
|
+
});
|
|
2783
|
+
}
|
|
2784
|
+
return S;
|
|
2785
|
+
}
|
|
2581
2786
|
}
|
|
2582
2787
|
function $e(T, E, e) {
|
|
2583
2788
|
const R = [];
|
|
2584
|
-
let A =
|
|
2585
|
-
const S =
|
|
2789
|
+
let A = _T(new Date(T), e);
|
|
2790
|
+
const S = _T(new Date(E), e), I = 1e4;
|
|
2586
2791
|
for (; A <= S && R.length < I; )
|
|
2587
2792
|
R.push(new Date(A)), A = we(A, e);
|
|
2588
2793
|
return R;
|
|
2589
2794
|
}
|
|
2590
|
-
function
|
|
2795
|
+
function _T(T, E) {
|
|
2591
2796
|
const e = new Date(T);
|
|
2592
2797
|
switch (E) {
|
|
2593
2798
|
case "second":
|
|
@@ -2670,24 +2875,24 @@ function ve(T, E) {
|
|
|
2670
2875
|
return T;
|
|
2671
2876
|
const O = /* @__PURE__ */ new Map();
|
|
2672
2877
|
for (const r of T) {
|
|
2673
|
-
const n = xe(r, t),
|
|
2674
|
-
O.has(n) || O.set(n, /* @__PURE__ */ new Map()), O.get(n).set(
|
|
2878
|
+
const n = xe(r, t), C = Je(r[e]);
|
|
2879
|
+
O.has(n) || O.set(n, /* @__PURE__ */ new Map()), O.get(n).set(C, r);
|
|
2675
2880
|
}
|
|
2676
2881
|
O.size === 0 && t.length === 0 && O.set("__all__", /* @__PURE__ */ new Map());
|
|
2677
2882
|
const N = [];
|
|
2678
2883
|
for (const [r, n] of O) {
|
|
2679
|
-
const
|
|
2884
|
+
const C = n.size > 0 ? n.values().next().value : null;
|
|
2680
2885
|
for (const i of s) {
|
|
2681
|
-
const
|
|
2886
|
+
const a = i.toISOString(), l = n.get(a);
|
|
2682
2887
|
if (l)
|
|
2683
2888
|
N.push(l);
|
|
2684
2889
|
else {
|
|
2685
2890
|
const P = {
|
|
2686
|
-
[e]:
|
|
2891
|
+
[e]: a
|
|
2687
2892
|
};
|
|
2688
|
-
if (
|
|
2893
|
+
if (C)
|
|
2689
2894
|
for (const U of t)
|
|
2690
|
-
P[U] =
|
|
2895
|
+
P[U] = C[U];
|
|
2691
2896
|
for (const U of I)
|
|
2692
2897
|
P[U] = S;
|
|
2693
2898
|
N.push(P);
|
|
@@ -2735,11 +2940,11 @@ function Ze(T, E, e) {
|
|
|
2735
2940
|
}
|
|
2736
2941
|
return t;
|
|
2737
2942
|
}
|
|
2738
|
-
class
|
|
2943
|
+
class mE {
|
|
2739
2944
|
constructor(E) {
|
|
2740
2945
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
2741
2946
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
2742
|
-
this.queryBuilder = new
|
|
2947
|
+
this.queryBuilder = new Ke(this.databaseAdapter), this.queryPlanner = new Te();
|
|
2743
2948
|
}
|
|
2744
2949
|
queryBuilder;
|
|
2745
2950
|
queryPlanner;
|
|
@@ -2749,7 +2954,7 @@ class GE {
|
|
|
2749
2954
|
*/
|
|
2750
2955
|
async execute(E, e, R) {
|
|
2751
2956
|
try {
|
|
2752
|
-
const A =
|
|
2957
|
+
const A = _e(E, e);
|
|
2753
2958
|
if (!A.isValid)
|
|
2754
2959
|
throw new Error(`Query validation failed: ${A.errors.join(", ")}`);
|
|
2755
2960
|
const S = {
|
|
@@ -2757,23 +2962,23 @@ class GE {
|
|
|
2757
2962
|
schema: this.dbExecutor.schema,
|
|
2758
2963
|
securityContext: R
|
|
2759
2964
|
}, I = this.queryPlanner.createQueryPlan(E, e, S), t = this.buildUnifiedQuery(I, e, S), s = this.queryBuilder.collectNumericFields(E, e), O = await this.dbExecutor.execute(t, s), N = Array.isArray(O) ? O.map((i) => {
|
|
2760
|
-
const
|
|
2965
|
+
const a = { ...i };
|
|
2761
2966
|
if (e.timeDimensions) {
|
|
2762
2967
|
for (const l of e.timeDimensions)
|
|
2763
|
-
if (l.dimension in
|
|
2764
|
-
let P =
|
|
2968
|
+
if (l.dimension in a) {
|
|
2969
|
+
let P = a[l.dimension];
|
|
2765
2970
|
if (typeof P == "string" && P.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
2766
2971
|
const U = P.replace(" ", "T"), M = !U.endsWith("Z") && !U.includes("+") ? U + "Z" : U;
|
|
2767
2972
|
P = new Date(M);
|
|
2768
2973
|
}
|
|
2769
|
-
P = this.databaseAdapter.convertTimeDimensionResult(P),
|
|
2974
|
+
P = this.databaseAdapter.convertTimeDimensionResult(P), a[l.dimension] = P;
|
|
2770
2975
|
}
|
|
2771
2976
|
}
|
|
2772
|
-
return
|
|
2773
|
-
}) : [O], r = e.measures || [], n = Ze(N, e, r),
|
|
2977
|
+
return a;
|
|
2978
|
+
}) : [O], r = e.measures || [], n = Ze(N, e, r), C = this.generateAnnotations(I, e);
|
|
2774
2979
|
return {
|
|
2775
2980
|
data: n,
|
|
2776
|
-
annotation:
|
|
2981
|
+
annotation: C
|
|
2777
2982
|
};
|
|
2778
2983
|
} catch (A) {
|
|
2779
2984
|
throw new Error(`Query execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
|
|
@@ -2795,7 +3000,7 @@ class GE {
|
|
|
2795
3000
|
if (P.targetColumnObj) {
|
|
2796
3001
|
t[P.targetColumn] = P.targetColumnObj;
|
|
2797
3002
|
for (const [U, M] of Object.entries(S.dimensions || {}))
|
|
2798
|
-
M.sql === P.targetColumnObj && U !== P.targetColumn && (t[U] =
|
|
3003
|
+
M.sql === P.targetColumnObj && U !== P.targetColumn && (t[U] = L`${P.targetColumnObj}`.as(U));
|
|
2799
3004
|
}
|
|
2800
3005
|
const s = S.name, O = /* @__PURE__ */ new Map([[s, S]]), N = this.queryBuilder.buildResolvedMeasures(
|
|
2801
3006
|
E.measures,
|
|
@@ -2806,7 +3011,7 @@ class GE {
|
|
|
2806
3011
|
const [, U] = P.split("."), M = N.get(P);
|
|
2807
3012
|
if (M) {
|
|
2808
3013
|
const G = M();
|
|
2809
|
-
t[U] =
|
|
3014
|
+
t[U] = L`${G}`.as(U);
|
|
2810
3015
|
}
|
|
2811
3016
|
}
|
|
2812
3017
|
if (e.dimensions)
|
|
@@ -2814,7 +3019,7 @@ class GE {
|
|
|
2814
3019
|
const [U, M] = P.split(".");
|
|
2815
3020
|
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2816
3021
|
const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R);
|
|
2817
|
-
t[M] =
|
|
3022
|
+
t[M] = L`${m}`.as(M);
|
|
2818
3023
|
}
|
|
2819
3024
|
}
|
|
2820
3025
|
if (e.timeDimensions)
|
|
@@ -2822,7 +3027,7 @@ class GE {
|
|
|
2822
3027
|
const [U, M] = P.dimension.split(".");
|
|
2823
3028
|
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2824
3029
|
const G = S.dimensions[M], m = this.queryBuilder.buildTimeDimensionExpression(G.sql, P.granularity, R);
|
|
2825
|
-
t[M] =
|
|
3030
|
+
t[M] = L`${m}`.as(M);
|
|
2826
3031
|
}
|
|
2827
3032
|
}
|
|
2828
3033
|
if (Object.keys(t).length === 0)
|
|
@@ -2831,13 +3036,13 @@ class GE {
|
|
|
2831
3036
|
const n = A ? {
|
|
2832
3037
|
...A,
|
|
2833
3038
|
preAggregationCTEs: A.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
|
|
2834
|
-
} : void 0,
|
|
3039
|
+
} : void 0, C = this.queryBuilder.buildWhereConditions(S, e, R, n), i = [];
|
|
2835
3040
|
if (e.timeDimensions)
|
|
2836
3041
|
for (const P of e.timeDimensions) {
|
|
2837
3042
|
const [U, M] = P.dimension.split(".");
|
|
2838
3043
|
if (U === s && S.dimensions && S.dimensions[M] && P.dateRange) {
|
|
2839
|
-
const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R),
|
|
2840
|
-
|
|
3044
|
+
const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R), p = this.queryBuilder.buildDateRangeCondition(m, P.dateRange);
|
|
3045
|
+
p && i.push(p);
|
|
2841
3046
|
}
|
|
2842
3047
|
}
|
|
2843
3048
|
if (e.filters) {
|
|
@@ -2847,15 +3052,15 @@ class GE {
|
|
|
2847
3052
|
if (M === s && S.dimensions && S.dimensions[G]) {
|
|
2848
3053
|
const m = S.dimensions[G];
|
|
2849
3054
|
if (U.operator === "inDateRange") {
|
|
2850
|
-
const
|
|
2851
|
-
|
|
3055
|
+
const p = this.queryBuilder.buildMeasureExpression({ sql: m.sql, type: "number" }, R), y = this.queryBuilder.buildDateRangeCondition(p, U.values);
|
|
3056
|
+
y && i.push(y);
|
|
2852
3057
|
}
|
|
2853
3058
|
}
|
|
2854
3059
|
}
|
|
2855
3060
|
}
|
|
2856
|
-
const
|
|
2857
|
-
if (I.where &&
|
|
2858
|
-
const P =
|
|
3061
|
+
const a = [];
|
|
3062
|
+
if (I.where && a.push(I.where), a.push(...C, ...i), a.length > 0) {
|
|
3063
|
+
const P = a.length === 1 ? a[0] : V(...a);
|
|
2859
3064
|
r = r.where(P);
|
|
2860
3065
|
}
|
|
2861
3066
|
const l = [];
|
|
@@ -2889,7 +3094,7 @@ class GE {
|
|
|
2889
3094
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
2890
3095
|
const S = [];
|
|
2891
3096
|
for (const I of A.joinKeys) {
|
|
2892
|
-
const t = I.sourceColumnObj ||
|
|
3097
|
+
const t = I.sourceColumnObj || L.identifier(I.sourceColumn), s = L`${L.identifier(e)}.${L.identifier(I.targetColumn)}`;
|
|
2893
3098
|
S.push(k(t, s));
|
|
2894
3099
|
}
|
|
2895
3100
|
return S.length === 1 ? S[0] : V(...S);
|
|
@@ -2900,9 +3105,9 @@ class GE {
|
|
|
2900
3105
|
buildUnifiedQuery(E, e, R) {
|
|
2901
3106
|
const A = [], S = /* @__PURE__ */ new Map();
|
|
2902
3107
|
if (E.preAggregationCTEs && E.preAggregationCTEs.length > 0)
|
|
2903
|
-
for (const
|
|
2904
|
-
const l = this.buildPreAggregationCTE(
|
|
2905
|
-
l && (A.push(l), S.set(
|
|
3108
|
+
for (const a of E.preAggregationCTEs) {
|
|
3109
|
+
const l = this.buildPreAggregationCTE(a, e, R, E);
|
|
3110
|
+
l && (A.push(l), S.set(a.cube.name, a.cteAlias));
|
|
2906
3111
|
}
|
|
2907
3112
|
const I = E.primaryCube.sql(R), s = { ...this.queryBuilder.buildSelections(
|
|
2908
3113
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2911,61 +3116,61 @@ class GE {
|
|
|
2911
3116
|
R
|
|
2912
3117
|
) };
|
|
2913
3118
|
if (E.preAggregationCTEs)
|
|
2914
|
-
for (const
|
|
2915
|
-
const l =
|
|
2916
|
-
for (const P of
|
|
3119
|
+
for (const a of E.preAggregationCTEs) {
|
|
3120
|
+
const l = a.cube.name;
|
|
3121
|
+
for (const P of a.measures)
|
|
2917
3122
|
if (s[P]) {
|
|
2918
3123
|
const [, U] = P.split("."), M = this.getCubesFromPlan(E).get(l);
|
|
2919
3124
|
if (M && M.measures && M.measures[U]) {
|
|
2920
3125
|
const G = M.measures[U];
|
|
2921
3126
|
let m;
|
|
2922
3127
|
if (G.type === "calculated" && G.calculatedSql) {
|
|
2923
|
-
const
|
|
3128
|
+
const p = this.getCubesFromPlan(E);
|
|
2924
3129
|
m = this.queryBuilder.buildCTECalculatedMeasure(
|
|
2925
3130
|
G,
|
|
2926
3131
|
M,
|
|
2927
|
-
|
|
2928
|
-
|
|
3132
|
+
a,
|
|
3133
|
+
p,
|
|
2929
3134
|
R
|
|
2930
3135
|
);
|
|
2931
3136
|
} else {
|
|
2932
|
-
const
|
|
3137
|
+
const p = L`${L.identifier(a.cteAlias)}.${L.identifier(U)}`;
|
|
2933
3138
|
switch (G.type) {
|
|
2934
3139
|
case "count":
|
|
2935
3140
|
case "countDistinct":
|
|
2936
3141
|
case "sum":
|
|
2937
|
-
m = g(
|
|
3142
|
+
m = g(p);
|
|
2938
3143
|
break;
|
|
2939
3144
|
case "avg":
|
|
2940
|
-
m = this.databaseAdapter.buildAvg(
|
|
3145
|
+
m = this.databaseAdapter.buildAvg(p);
|
|
2941
3146
|
break;
|
|
2942
3147
|
case "min":
|
|
2943
|
-
m = SE(
|
|
3148
|
+
m = SE(p);
|
|
2944
3149
|
break;
|
|
2945
3150
|
case "max":
|
|
2946
|
-
m = AE(
|
|
3151
|
+
m = AE(p);
|
|
2947
3152
|
break;
|
|
2948
3153
|
case "number":
|
|
2949
|
-
m = g(
|
|
3154
|
+
m = g(p);
|
|
2950
3155
|
break;
|
|
2951
3156
|
default:
|
|
2952
|
-
m = g(
|
|
3157
|
+
m = g(p);
|
|
2953
3158
|
}
|
|
2954
3159
|
}
|
|
2955
|
-
s[P] =
|
|
3160
|
+
s[P] = L`${m}`.as(P);
|
|
2956
3161
|
}
|
|
2957
3162
|
}
|
|
2958
3163
|
for (const P in s) {
|
|
2959
3164
|
const [U, M] = P.split(".");
|
|
2960
3165
|
if (U === l) {
|
|
2961
|
-
const G = this.getCubesFromPlan(E).get(l), m = G && G.dimensions?.[M],
|
|
2962
|
-
if (m ||
|
|
2963
|
-
let
|
|
2964
|
-
if (!
|
|
3166
|
+
const G = this.getCubesFromPlan(E).get(l), m = G && G.dimensions?.[M], p = P.startsWith(l + ".");
|
|
3167
|
+
if (m || p) {
|
|
3168
|
+
let y = a.joinKeys.find((_E) => _E.targetColumn === M);
|
|
3169
|
+
if (!y && G?.dimensions?.[M]) {
|
|
2965
3170
|
const _E = G.dimensions[M].sql;
|
|
2966
|
-
|
|
3171
|
+
y = a.joinKeys.find((ae) => ae.targetColumnObj === _E);
|
|
2967
3172
|
}
|
|
2968
|
-
|
|
3173
|
+
y ? s[P] = L`${L.identifier(a.cteAlias)}.${L.identifier(M)}`.as(P) : p && G?.dimensions?.[M] && (s[P] = L`${L.identifier(a.cteAlias)}.${L.identifier(M)}`.as(P));
|
|
2969
3174
|
}
|
|
2970
3175
|
}
|
|
2971
3176
|
}
|
|
@@ -2973,26 +3178,26 @@ class GE {
|
|
|
2973
3178
|
const O = [];
|
|
2974
3179
|
let N = R.db.select(s).from(I.from);
|
|
2975
3180
|
if (A.length > 0 && (N = R.db.with(...A).select(s).from(I.from)), I.joins)
|
|
2976
|
-
for (const
|
|
2977
|
-
switch (
|
|
3181
|
+
for (const a of I.joins)
|
|
3182
|
+
switch (a.type || "left") {
|
|
2978
3183
|
case "left":
|
|
2979
|
-
N = N.leftJoin(
|
|
3184
|
+
N = N.leftJoin(a.table, a.on);
|
|
2980
3185
|
break;
|
|
2981
3186
|
case "inner":
|
|
2982
|
-
N = N.innerJoin(
|
|
3187
|
+
N = N.innerJoin(a.table, a.on);
|
|
2983
3188
|
break;
|
|
2984
3189
|
case "right":
|
|
2985
|
-
N = N.rightJoin(
|
|
3190
|
+
N = N.rightJoin(a.table, a.on);
|
|
2986
3191
|
break;
|
|
2987
3192
|
case "full":
|
|
2988
|
-
N = N.fullJoin(
|
|
3193
|
+
N = N.fullJoin(a.table, a.on);
|
|
2989
3194
|
break;
|
|
2990
3195
|
}
|
|
2991
3196
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
2992
|
-
for (const
|
|
2993
|
-
const l = S.get(
|
|
2994
|
-
if (
|
|
2995
|
-
const M =
|
|
3197
|
+
for (const a of E.joinCubes) {
|
|
3198
|
+
const l = S.get(a.cube.name);
|
|
3199
|
+
if (a.junctionTable) {
|
|
3200
|
+
const M = a.junctionTable, G = [];
|
|
2996
3201
|
if (M.securitySql) {
|
|
2997
3202
|
const m = M.securitySql(R.securityContext);
|
|
2998
3203
|
Array.isArray(m) ? G.push(...m) : G.push(m);
|
|
@@ -3017,9 +3222,9 @@ class GE {
|
|
|
3017
3222
|
}
|
|
3018
3223
|
}
|
|
3019
3224
|
let P, U;
|
|
3020
|
-
l ? (P =
|
|
3225
|
+
l ? (P = L`${L.identifier(l)}`, U = this.buildCTEJoinCondition(a, l, E)) : (P = a.cube.sql(R).from, U = a.joinCondition);
|
|
3021
3226
|
try {
|
|
3022
|
-
switch (
|
|
3227
|
+
switch (a.joinType || "left") {
|
|
3023
3228
|
case "left":
|
|
3024
3229
|
N = N.leftJoin(P, U);
|
|
3025
3230
|
break;
|
|
@@ -3037,10 +3242,10 @@ class GE {
|
|
|
3037
3242
|
}
|
|
3038
3243
|
}
|
|
3039
3244
|
if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
|
|
3040
|
-
for (const
|
|
3041
|
-
if (S.get(
|
|
3245
|
+
for (const a of E.joinCubes) {
|
|
3246
|
+
if (S.get(a.cube.name))
|
|
3042
3247
|
continue;
|
|
3043
|
-
const P =
|
|
3248
|
+
const P = a.cube.sql(R);
|
|
3044
3249
|
P.where && O.push(P.where);
|
|
3045
3250
|
}
|
|
3046
3251
|
const r = this.queryBuilder.buildWhereConditions(
|
|
@@ -3052,8 +3257,8 @@ class GE {
|
|
|
3052
3257
|
// Pass the queryPlan to handle CTE scenarios
|
|
3053
3258
|
);
|
|
3054
3259
|
if (r.length > 0 && O.push(...r), O.length > 0) {
|
|
3055
|
-
const
|
|
3056
|
-
N = N.where(
|
|
3260
|
+
const a = O.length === 1 ? O[0] : V(...O);
|
|
3261
|
+
N = N.where(a);
|
|
3057
3262
|
}
|
|
3058
3263
|
const n = this.queryBuilder.buildGroupByFields(
|
|
3059
3264
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -3064,7 +3269,7 @@ class GE {
|
|
|
3064
3269
|
// Pass the queryPlan to handle CTE scenarios
|
|
3065
3270
|
);
|
|
3066
3271
|
n.length > 0 && (N = N.groupBy(...n));
|
|
3067
|
-
const
|
|
3272
|
+
const C = this.queryBuilder.buildHavingConditions(
|
|
3068
3273
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
3069
3274
|
// Single cube
|
|
3070
3275
|
e,
|
|
@@ -3072,9 +3277,9 @@ class GE {
|
|
|
3072
3277
|
E
|
|
3073
3278
|
// Pass the queryPlan to handle CTE scenarios
|
|
3074
3279
|
);
|
|
3075
|
-
if (
|
|
3076
|
-
const
|
|
3077
|
-
N = N.having(
|
|
3280
|
+
if (C.length > 0) {
|
|
3281
|
+
const a = C.length === 1 ? C[0] : V(...C);
|
|
3282
|
+
N = N.having(a);
|
|
3078
3283
|
}
|
|
3079
3284
|
const i = this.queryBuilder.buildOrderBy(e);
|
|
3080
3285
|
return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, e), N;
|
|
@@ -3166,10 +3371,10 @@ class GE {
|
|
|
3166
3371
|
};
|
|
3167
3372
|
}
|
|
3168
3373
|
}
|
|
3169
|
-
const _ = (T) => T.flatMap(qe), qe = (T) =>
|
|
3374
|
+
const _ = (T) => T.flatMap(qe), qe = (T) => NE(ke(T)).map(je), je = (T) => T.replace(/ +/g, " ").trim(), ke = (T) => ({
|
|
3170
3375
|
type: "mandatory_block",
|
|
3171
|
-
items:
|
|
3172
|
-
}),
|
|
3376
|
+
items: eT(T, 0)[0]
|
|
3377
|
+
}), eT = (T, E, e) => {
|
|
3173
3378
|
const R = [];
|
|
3174
3379
|
for (; T[E]; ) {
|
|
3175
3380
|
const [A, S] = ze(T, E);
|
|
@@ -3209,20 +3414,20 @@ const _ = (T) => T.flatMap(qe), qe = (T) => IE(ke(T)).map(je), je = (T) => T.rep
|
|
|
3209
3414
|
return [e, E];
|
|
3210
3415
|
}
|
|
3211
3416
|
}, TR = (T, E) => {
|
|
3212
|
-
const [e, R] =
|
|
3417
|
+
const [e, R] = eT(T, E, "}");
|
|
3213
3418
|
return [{ type: "mandatory_block", items: e }, R];
|
|
3214
3419
|
}, eR = (T, E) => {
|
|
3215
|
-
const [e, R] =
|
|
3420
|
+
const [e, R] = eT(T, E, "]");
|
|
3216
3421
|
return [{ type: "optional_block", items: e }, R];
|
|
3217
|
-
},
|
|
3422
|
+
}, NE = (T) => {
|
|
3218
3423
|
if (typeof T == "string")
|
|
3219
3424
|
return [T];
|
|
3220
3425
|
if (T.type === "concatenation")
|
|
3221
|
-
return T.items.map(
|
|
3426
|
+
return T.items.map(NE).reduce(RR, [""]);
|
|
3222
3427
|
if (T.type === "mandatory_block")
|
|
3223
|
-
return T.items.flatMap(
|
|
3428
|
+
return T.items.flatMap(NE);
|
|
3224
3429
|
if (T.type === "optional_block")
|
|
3225
|
-
return ["", ...T.items.flatMap(
|
|
3430
|
+
return ["", ...T.items.flatMap(NE)];
|
|
3226
3431
|
throw new Error(`Unknown node type: ${T}`);
|
|
3227
3432
|
}, RR = (T, E) => {
|
|
3228
3433
|
const e = [];
|
|
@@ -3231,23 +3436,23 @@ const _ = (T) => T.flatMap(qe), qe = (T) => IE(ke(T)).map(je), je = (T) => T.rep
|
|
|
3231
3436
|
e.push(R + A);
|
|
3232
3437
|
return e;
|
|
3233
3438
|
};
|
|
3234
|
-
var
|
|
3439
|
+
var D;
|
|
3235
3440
|
(function(T) {
|
|
3236
3441
|
T.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", T.IDENTIFIER = "IDENTIFIER", T.STRING = "STRING", T.VARIABLE = "VARIABLE", T.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", T.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", T.RESERVED_KEYWORD = "RESERVED_KEYWORD", T.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", T.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", T.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", T.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", T.RESERVED_CLAUSE = "RESERVED_CLAUSE", T.RESERVED_SELECT = "RESERVED_SELECT", T.RESERVED_JOIN = "RESERVED_JOIN", T.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", T.ARRAY_KEYWORD = "ARRAY_KEYWORD", T.CASE = "CASE", T.END = "END", T.WHEN = "WHEN", T.ELSE = "ELSE", T.THEN = "THEN", T.LIMIT = "LIMIT", T.BETWEEN = "BETWEEN", T.AND = "AND", T.OR = "OR", T.XOR = "XOR", T.OPERATOR = "OPERATOR", T.COMMA = "COMMA", T.ASTERISK = "ASTERISK", T.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", T.OPEN_PAREN = "OPEN_PAREN", T.CLOSE_PAREN = "CLOSE_PAREN", T.LINE_COMMENT = "LINE_COMMENT", T.BLOCK_COMMENT = "BLOCK_COMMENT", T.DISABLE_COMMENT = "DISABLE_COMMENT", T.NUMBER = "NUMBER", T.NAMED_PARAMETER = "NAMED_PARAMETER", T.QUOTED_PARAMETER = "QUOTED_PARAMETER", T.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", T.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", T.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", T.DELIMITER = "DELIMITER", T.EOF = "EOF";
|
|
3237
|
-
})(
|
|
3238
|
-
const
|
|
3239
|
-
type:
|
|
3442
|
+
})(D = D || (D = {}));
|
|
3443
|
+
const ee = (T) => ({
|
|
3444
|
+
type: D.EOF,
|
|
3240
3445
|
raw: "«EOF»",
|
|
3241
3446
|
text: "«EOF»",
|
|
3242
3447
|
start: T
|
|
3243
|
-
}), z =
|
|
3244
|
-
ARRAY: q({ text: "ARRAY", type:
|
|
3245
|
-
BY: q({ text: "BY", type:
|
|
3246
|
-
SET: q({ text: "SET", type:
|
|
3247
|
-
STRUCT: q({ text: "STRUCT", type:
|
|
3248
|
-
WINDOW: q({ text: "WINDOW", type:
|
|
3249
|
-
VALUES: q({ text: "VALUES", type:
|
|
3250
|
-
},
|
|
3448
|
+
}), z = ee(1 / 0), q = (T) => (E) => E.type === T.type && E.text === T.text, x = {
|
|
3449
|
+
ARRAY: q({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
|
|
3450
|
+
BY: q({ text: "BY", type: D.RESERVED_KEYWORD }),
|
|
3451
|
+
SET: q({ text: "SET", type: D.RESERVED_CLAUSE }),
|
|
3452
|
+
STRUCT: q({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
|
|
3453
|
+
WINDOW: q({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
|
|
3454
|
+
VALUES: q({ text: "VALUES", type: D.RESERVED_CLAUSE })
|
|
3455
|
+
}, Re = (T) => T === D.RESERVED_DATA_TYPE || T === D.RESERVED_KEYWORD || T === D.RESERVED_FUNCTION_NAME || T === D.RESERVED_KEYWORD_PHRASE || T === D.RESERVED_DATA_TYPE_PHRASE || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.ARRAY_KEYWORD || T === D.CASE || T === D.END || T === D.WHEN || T === D.ELSE || T === D.THEN || T === D.LIMIT || T === D.BETWEEN || T === D.AND || T === D.OR || T === D.XOR, AR = (T) => T === D.AND || T === D.OR || T === D.XOR, SR = [
|
|
3251
3456
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
3252
3457
|
"KEYS.NEW_KEYSET",
|
|
3253
3458
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -3791,7 +3996,7 @@ const Te = (T) => ({
|
|
|
3791
3996
|
// pivot
|
|
3792
3997
|
"PIVOT",
|
|
3793
3998
|
"UNPIVOT"
|
|
3794
|
-
],
|
|
3999
|
+
], NR = [
|
|
3795
4000
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
|
|
3796
4001
|
"ALL",
|
|
3797
4002
|
"AND",
|
|
@@ -3899,7 +4104,7 @@ const Te = (T) => ({
|
|
|
3899
4104
|
"CASCADE",
|
|
3900
4105
|
"RESTRICT",
|
|
3901
4106
|
"DETERMINISTIC"
|
|
3902
|
-
],
|
|
4107
|
+
], IR = [
|
|
3903
4108
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
|
|
3904
4109
|
"ARRAY",
|
|
3905
4110
|
"BOOL",
|
|
@@ -3953,9 +4158,9 @@ const Te = (T) => ({
|
|
|
3953
4158
|
"WITH CONNECTION",
|
|
3954
4159
|
"WITH PARTITION COLUMNS",
|
|
3955
4160
|
"REMOTE WITH CONNECTION"
|
|
3956
|
-
]),
|
|
4161
|
+
]), iT = _([
|
|
3957
4162
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3958
|
-
]),
|
|
4163
|
+
]), dE = _([
|
|
3959
4164
|
// - create:
|
|
3960
4165
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
3961
4166
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -4047,11 +4252,11 @@ const Te = (T) => ({
|
|
|
4047
4252
|
"UNION {ALL | DISTINCT}",
|
|
4048
4253
|
"EXCEPT DISTINCT",
|
|
4049
4254
|
"INTERSECT DISTINCT"
|
|
4050
|
-
]),
|
|
4255
|
+
]), nR = _([
|
|
4051
4256
|
"JOIN",
|
|
4052
4257
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4053
4258
|
"{INNER | CROSS} JOIN"
|
|
4054
|
-
]),
|
|
4259
|
+
]), CR = _([
|
|
4055
4260
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
4056
4261
|
"TABLESAMPLE SYSTEM",
|
|
4057
4262
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -4066,13 +4271,13 @@ const Te = (T) => ({
|
|
|
4066
4271
|
name: "bigquery",
|
|
4067
4272
|
tokenizerOptions: {
|
|
4068
4273
|
reservedSelect: tR,
|
|
4069
|
-
reservedClauses: [...sR, ...
|
|
4274
|
+
reservedClauses: [...sR, ...dE, ...iT],
|
|
4070
4275
|
reservedSetOperations: rR,
|
|
4071
|
-
reservedJoins:
|
|
4072
|
-
reservedKeywordPhrases:
|
|
4276
|
+
reservedJoins: nR,
|
|
4277
|
+
reservedKeywordPhrases: CR,
|
|
4073
4278
|
reservedDataTypePhrases: LR,
|
|
4074
|
-
reservedKeywords:
|
|
4075
|
-
reservedDataTypes:
|
|
4279
|
+
reservedKeywords: NR,
|
|
4280
|
+
reservedDataTypes: IR,
|
|
4076
4281
|
reservedFunctionNames: SR,
|
|
4077
4282
|
extraParens: ["[]"],
|
|
4078
4283
|
stringTypes: [
|
|
@@ -4094,8 +4299,8 @@ const Te = (T) => ({
|
|
|
4094
4299
|
postProcess: iR
|
|
4095
4300
|
},
|
|
4096
4301
|
formatOptions: {
|
|
4097
|
-
onelineClauses: [...
|
|
4098
|
-
tabularOnelineClauses:
|
|
4302
|
+
onelineClauses: [...iT, ...dE],
|
|
4303
|
+
tabularOnelineClauses: dE
|
|
4099
4304
|
}
|
|
4100
4305
|
};
|
|
4101
4306
|
function iR(T) {
|
|
@@ -4103,7 +4308,7 @@ function iR(T) {
|
|
|
4103
4308
|
}
|
|
4104
4309
|
function aR(T) {
|
|
4105
4310
|
let E = z;
|
|
4106
|
-
return T.map((e) => e.text === "OFFSET" && E.text === "[" ? (E = e, Object.assign(Object.assign({}, e), { type:
|
|
4311
|
+
return T.map((e) => e.text === "OFFSET" && E.text === "[" ? (E = e, Object.assign(Object.assign({}, e), { type: D.RESERVED_FUNCTION_NAME })) : (E = e, e));
|
|
4107
4312
|
}
|
|
4108
4313
|
function oR(T) {
|
|
4109
4314
|
var E;
|
|
@@ -4113,9 +4318,9 @@ function oR(T) {
|
|
|
4113
4318
|
if ((x.ARRAY(A) || x.STRUCT(A)) && ((E = T[R + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
4114
4319
|
const S = DR(T, R + 1), I = T.slice(R, S + 1);
|
|
4115
4320
|
e.push({
|
|
4116
|
-
type:
|
|
4117
|
-
raw: I.map(
|
|
4118
|
-
text: I.map(
|
|
4321
|
+
type: D.IDENTIFIER,
|
|
4322
|
+
raw: I.map(aT("raw")).join(""),
|
|
4323
|
+
text: I.map(aT("text")).join(""),
|
|
4119
4324
|
start: A.start
|
|
4120
4325
|
}), R = S;
|
|
4121
4326
|
} else
|
|
@@ -4123,7 +4328,7 @@ function oR(T) {
|
|
|
4123
4328
|
}
|
|
4124
4329
|
return e;
|
|
4125
4330
|
}
|
|
4126
|
-
const
|
|
4331
|
+
const aT = (T) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[T] + " " : E[T];
|
|
4127
4332
|
function DR(T, E) {
|
|
4128
4333
|
let e = 0;
|
|
4129
4334
|
for (let R = E; R < T.length; R++) {
|
|
@@ -4925,9 +5130,9 @@ const PR = [
|
|
|
4925
5130
|
"WHEN [NOT] MATCHED [THEN]",
|
|
4926
5131
|
"UPDATE SET",
|
|
4927
5132
|
"INSERT"
|
|
4928
|
-
]),
|
|
5133
|
+
]), oT = _([
|
|
4929
5134
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
4930
|
-
]),
|
|
5135
|
+
]), HE = _([
|
|
4931
5136
|
// - create:
|
|
4932
5137
|
"CREATE [OR REPLACE] VIEW",
|
|
4933
5138
|
// - update:
|
|
@@ -5143,7 +5348,7 @@ const PR = [
|
|
|
5143
5348
|
name: "db2",
|
|
5144
5349
|
tokenizerOptions: {
|
|
5145
5350
|
reservedSelect: cR,
|
|
5146
|
-
reservedClauses: [...lR, ...
|
|
5351
|
+
reservedClauses: [...lR, ...oT, ...HE],
|
|
5147
5352
|
reservedSetOperations: uR,
|
|
5148
5353
|
reservedJoins: GR,
|
|
5149
5354
|
reservedKeywordPhrases: mR,
|
|
@@ -5181,10 +5386,10 @@ const PR = [
|
|
|
5181
5386
|
]
|
|
5182
5387
|
},
|
|
5183
5388
|
formatOptions: {
|
|
5184
|
-
onelineClauses: [...
|
|
5185
|
-
tabularOnelineClauses:
|
|
5389
|
+
onelineClauses: [...oT, ...HE],
|
|
5390
|
+
tabularOnelineClauses: HE
|
|
5186
5391
|
}
|
|
5187
|
-
},
|
|
5392
|
+
}, pR = [
|
|
5188
5393
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
5189
5394
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
5190
5395
|
"ARRAY_AGG",
|
|
@@ -5518,7 +5723,7 @@ const PR = [
|
|
|
5518
5723
|
"ROW_NUMBER",
|
|
5519
5724
|
// Type casting
|
|
5520
5725
|
"CAST"
|
|
5521
|
-
],
|
|
5726
|
+
], BR = [
|
|
5522
5727
|
// https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
|
|
5523
5728
|
// TODO: This list likely contains all keywords, not only the reserved ones,
|
|
5524
5729
|
// try to filter it down to just the reserved keywords.
|
|
@@ -6080,7 +6285,7 @@ const PR = [
|
|
|
6080
6285
|
"INSERT",
|
|
6081
6286
|
// Data definition - table
|
|
6082
6287
|
"FOR SYSTEM NAME"
|
|
6083
|
-
]),
|
|
6288
|
+
]), DT = _(["CREATE [OR REPLACE] TABLE"]), pE = _([
|
|
6084
6289
|
// - create:
|
|
6085
6290
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
6086
6291
|
// - update:
|
|
@@ -6181,23 +6386,23 @@ const PR = [
|
|
|
6181
6386
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6182
6387
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
6183
6388
|
"{INNER | CROSS} JOIN"
|
|
6184
|
-
]),
|
|
6389
|
+
]), bR = _([
|
|
6185
6390
|
"ON DELETE",
|
|
6186
6391
|
"ON UPDATE",
|
|
6187
6392
|
"SET NULL",
|
|
6188
6393
|
"{ROWS | RANGE} BETWEEN"
|
|
6189
|
-
]),
|
|
6394
|
+
]), WR = _([]), yR = {
|
|
6190
6395
|
name: "db2i",
|
|
6191
6396
|
tokenizerOptions: {
|
|
6192
6397
|
reservedSelect: YR,
|
|
6193
|
-
reservedClauses: [...fR, ...
|
|
6398
|
+
reservedClauses: [...fR, ...DT, ...pE],
|
|
6194
6399
|
reservedSetOperations: hR,
|
|
6195
6400
|
reservedJoins: VR,
|
|
6196
|
-
reservedKeywordPhrases:
|
|
6197
|
-
reservedDataTypePhrases:
|
|
6198
|
-
reservedKeywords:
|
|
6401
|
+
reservedKeywordPhrases: bR,
|
|
6402
|
+
reservedDataTypePhrases: WR,
|
|
6403
|
+
reservedKeywords: BR,
|
|
6199
6404
|
reservedDataTypes: FR,
|
|
6200
|
-
reservedFunctionNames:
|
|
6405
|
+
reservedFunctionNames: pR,
|
|
6201
6406
|
nestedBlockComments: !0,
|
|
6202
6407
|
extraParens: ["[]"],
|
|
6203
6408
|
stringTypes: [
|
|
@@ -6211,10 +6416,10 @@ const PR = [
|
|
|
6211
6416
|
operators: ["**", "¬=", "¬>", "¬<", "!>", "!<", "||", "=>"]
|
|
6212
6417
|
},
|
|
6213
6418
|
formatOptions: {
|
|
6214
|
-
onelineClauses: [...
|
|
6215
|
-
tabularOnelineClauses:
|
|
6419
|
+
onelineClauses: [...DT, ...pE],
|
|
6420
|
+
tabularOnelineClauses: pE
|
|
6216
6421
|
}
|
|
6217
|
-
},
|
|
6422
|
+
}, XR = [
|
|
6218
6423
|
// Functions from DuckDB (excluding those that start with an underscore):
|
|
6219
6424
|
// SELECT DISTINCT upper(function_name) AS function_name
|
|
6220
6425
|
// FROM duckdb_functions()
|
|
@@ -7063,7 +7268,7 @@ const PR = [
|
|
|
7063
7268
|
"SET",
|
|
7064
7269
|
// other:
|
|
7065
7270
|
"RETURNING"
|
|
7066
|
-
]),
|
|
7271
|
+
]), PT = _([
|
|
7067
7272
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
7068
7273
|
]), BE = _([
|
|
7069
7274
|
// TABLE
|
|
@@ -7164,7 +7369,7 @@ const PR = [
|
|
|
7164
7369
|
name: "duckdb",
|
|
7165
7370
|
tokenizerOptions: {
|
|
7166
7371
|
reservedSelect: $R,
|
|
7167
|
-
reservedClauses: [...wR, ...
|
|
7372
|
+
reservedClauses: [...wR, ...PT, ...BE],
|
|
7168
7373
|
reservedSetOperations: JR,
|
|
7169
7374
|
reservedJoins: xR,
|
|
7170
7375
|
reservedKeywordPhrases: vR,
|
|
@@ -7172,7 +7377,7 @@ const PR = [
|
|
|
7172
7377
|
supportsXor: !0,
|
|
7173
7378
|
reservedKeywords: gR,
|
|
7174
7379
|
reservedDataTypes: KR,
|
|
7175
|
-
reservedFunctionNames:
|
|
7380
|
+
reservedFunctionNames: XR,
|
|
7176
7381
|
nestedBlockComments: !0,
|
|
7177
7382
|
extraParens: ["[]", "{}"],
|
|
7178
7383
|
underscoresInNumbers: !0,
|
|
@@ -7233,7 +7438,7 @@ const PR = [
|
|
|
7233
7438
|
},
|
|
7234
7439
|
formatOptions: {
|
|
7235
7440
|
alwaysDenseOperators: ["::"],
|
|
7236
|
-
onelineClauses: [...
|
|
7441
|
+
onelineClauses: [...PT, ...BE],
|
|
7237
7442
|
tabularOnelineClauses: BE
|
|
7238
7443
|
}
|
|
7239
7444
|
}, qR = [
|
|
@@ -7814,9 +8019,9 @@ const PR = [
|
|
|
7814
8019
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
7815
8020
|
"LOAD DATA [LOCAL] INPATH",
|
|
7816
8021
|
"[OVERWRITE] INTO TABLE"
|
|
7817
|
-
]),
|
|
8022
|
+
]), MT = _([
|
|
7818
8023
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
7819
|
-
]),
|
|
8024
|
+
]), FE = _([
|
|
7820
8025
|
// - create:
|
|
7821
8026
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
7822
8027
|
// - update:
|
|
@@ -7851,7 +8056,7 @@ const PR = [
|
|
|
7851
8056
|
name: "hive",
|
|
7852
8057
|
tokenizerOptions: {
|
|
7853
8058
|
reservedSelect: zR,
|
|
7854
|
-
reservedClauses: [...EA, ...
|
|
8059
|
+
reservedClauses: [...EA, ...MT, ...FE],
|
|
7855
8060
|
reservedSetOperations: TA,
|
|
7856
8061
|
reservedJoins: eA,
|
|
7857
8062
|
reservedKeywordPhrases: RA,
|
|
@@ -7866,20 +8071,20 @@ const PR = [
|
|
|
7866
8071
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||"]
|
|
7867
8072
|
},
|
|
7868
8073
|
formatOptions: {
|
|
7869
|
-
onelineClauses: [...
|
|
7870
|
-
tabularOnelineClauses:
|
|
8074
|
+
onelineClauses: [...MT, ...FE],
|
|
8075
|
+
tabularOnelineClauses: FE
|
|
7871
8076
|
}
|
|
7872
8077
|
};
|
|
7873
8078
|
function LE(T) {
|
|
7874
8079
|
return T.map((E, e) => {
|
|
7875
8080
|
const R = T[e + 1] || z;
|
|
7876
8081
|
if (x.SET(E) && R.text === "(")
|
|
7877
|
-
return Object.assign(Object.assign({}, E), { type:
|
|
8082
|
+
return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
|
|
7878
8083
|
const A = T[e - 1] || z;
|
|
7879
|
-
return x.VALUES(E) && A.text === "=" ? Object.assign(Object.assign({}, E), { type:
|
|
8084
|
+
return x.VALUES(E) && A.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
|
|
7880
8085
|
});
|
|
7881
8086
|
}
|
|
7882
|
-
const
|
|
8087
|
+
const NA = [
|
|
7883
8088
|
// https://mariadb.com/kb/en/reserved-words/
|
|
7884
8089
|
"ACCESSIBLE",
|
|
7885
8090
|
"ADD",
|
|
@@ -8096,7 +8301,7 @@ const IA = [
|
|
|
8096
8301
|
"XOR",
|
|
8097
8302
|
"YEAR_MONTH",
|
|
8098
8303
|
"ZEROFILL"
|
|
8099
|
-
],
|
|
8304
|
+
], IA = [
|
|
8100
8305
|
// https://mariadb.com/kb/en/data-types/
|
|
8101
8306
|
"BIGINT",
|
|
8102
8307
|
"BINARY",
|
|
@@ -8407,9 +8612,9 @@ const IA = [
|
|
|
8407
8612
|
"SET",
|
|
8408
8613
|
// other
|
|
8409
8614
|
"RETURNING"
|
|
8410
|
-
]),
|
|
8615
|
+
]), UT = _([
|
|
8411
8616
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
8412
|
-
]),
|
|
8617
|
+
]), YE = _([
|
|
8413
8618
|
// - create:
|
|
8414
8619
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8415
8620
|
// - update:
|
|
@@ -8621,7 +8826,7 @@ const IA = [
|
|
|
8621
8826
|
"EXCEPT [ALL | DISTINCT]",
|
|
8622
8827
|
"INTERSECT [ALL | DISTINCT]",
|
|
8623
8828
|
"MINUS [ALL | DISTINCT]"
|
|
8624
|
-
]),
|
|
8829
|
+
]), nA = _([
|
|
8625
8830
|
"JOIN",
|
|
8626
8831
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8627
8832
|
"{INNER | CROSS} JOIN",
|
|
@@ -8629,7 +8834,7 @@ const IA = [
|
|
|
8629
8834
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8630
8835
|
// non-standard joins
|
|
8631
8836
|
"STRAIGHT_JOIN"
|
|
8632
|
-
]),
|
|
8837
|
+
]), CA = _([
|
|
8633
8838
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
8634
8839
|
"CHARACTER SET",
|
|
8635
8840
|
"{ROWS | RANGE} BETWEEN",
|
|
@@ -8638,14 +8843,14 @@ const IA = [
|
|
|
8638
8843
|
name: "mariadb",
|
|
8639
8844
|
tokenizerOptions: {
|
|
8640
8845
|
reservedSelect: tA,
|
|
8641
|
-
reservedClauses: [...sA, ...
|
|
8846
|
+
reservedClauses: [...sA, ...UT, ...YE],
|
|
8642
8847
|
reservedSetOperations: rA,
|
|
8643
|
-
reservedJoins:
|
|
8644
|
-
reservedKeywordPhrases:
|
|
8848
|
+
reservedJoins: nA,
|
|
8849
|
+
reservedKeywordPhrases: CA,
|
|
8645
8850
|
reservedDataTypePhrases: LA,
|
|
8646
8851
|
supportsXor: !0,
|
|
8647
|
-
reservedKeywords:
|
|
8648
|
-
reservedDataTypes:
|
|
8852
|
+
reservedKeywords: NA,
|
|
8853
|
+
reservedDataTypes: IA,
|
|
8649
8854
|
reservedFunctionNames: OA,
|
|
8650
8855
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
8651
8856
|
stringTypes: [
|
|
@@ -8682,8 +8887,8 @@ const IA = [
|
|
|
8682
8887
|
postProcess: LE
|
|
8683
8888
|
},
|
|
8684
8889
|
formatOptions: {
|
|
8685
|
-
onelineClauses: [...
|
|
8686
|
-
tabularOnelineClauses:
|
|
8890
|
+
onelineClauses: [...UT, ...YE],
|
|
8891
|
+
tabularOnelineClauses: YE
|
|
8687
8892
|
}
|
|
8688
8893
|
}, iA = [
|
|
8689
8894
|
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
|
|
@@ -9411,7 +9616,7 @@ const IA = [
|
|
|
9411
9616
|
"ON DUPLICATE KEY UPDATE",
|
|
9412
9617
|
// - update:
|
|
9413
9618
|
"SET"
|
|
9414
|
-
]),
|
|
9619
|
+
]), cT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), fE = _([
|
|
9415
9620
|
// - create:
|
|
9416
9621
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9417
9622
|
// - update:
|
|
@@ -9609,7 +9814,7 @@ const IA = [
|
|
|
9609
9814
|
name: "mysql",
|
|
9610
9815
|
tokenizerOptions: {
|
|
9611
9816
|
reservedSelect: DA,
|
|
9612
|
-
reservedClauses: [...PA, ...
|
|
9817
|
+
reservedClauses: [...PA, ...cT, ...fE],
|
|
9613
9818
|
reservedSetOperations: MA,
|
|
9614
9819
|
reservedJoins: UA,
|
|
9615
9820
|
reservedKeywordPhrases: cA,
|
|
@@ -9655,8 +9860,8 @@ const IA = [
|
|
|
9655
9860
|
postProcess: LE
|
|
9656
9861
|
},
|
|
9657
9862
|
formatOptions: {
|
|
9658
|
-
onelineClauses: [...
|
|
9659
|
-
tabularOnelineClauses:
|
|
9863
|
+
onelineClauses: [...cT, ...fE],
|
|
9864
|
+
tabularOnelineClauses: fE
|
|
9660
9865
|
}
|
|
9661
9866
|
}, GA = [
|
|
9662
9867
|
// https://docs.pingcap.com/tidb/stable/keywords
|
|
@@ -10223,7 +10428,7 @@ const IA = [
|
|
|
10223
10428
|
// 'XOR',
|
|
10224
10429
|
"YEAR",
|
|
10225
10430
|
"YEARWEEK"
|
|
10226
|
-
], HA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),
|
|
10431
|
+
], HA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), pA = _([
|
|
10227
10432
|
// queries
|
|
10228
10433
|
"WITH [RECURSIVE]",
|
|
10229
10434
|
"FROM",
|
|
@@ -10243,7 +10448,7 @@ const IA = [
|
|
|
10243
10448
|
"ON DUPLICATE KEY UPDATE",
|
|
10244
10449
|
// - update:
|
|
10245
10450
|
"SET"
|
|
10246
|
-
]),
|
|
10451
|
+
]), lT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), hE = _([
|
|
10247
10452
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
10248
10453
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
10249
10454
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -10358,7 +10563,7 @@ const IA = [
|
|
|
10358
10563
|
"UNLOCK TABLES",
|
|
10359
10564
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
10360
10565
|
"USE"
|
|
10361
|
-
]),
|
|
10566
|
+
]), BA = _(["UNION [ALL | DISTINCT]"]), FA = _([
|
|
10362
10567
|
"JOIN",
|
|
10363
10568
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
10364
10569
|
"{INNER | CROSS} JOIN",
|
|
@@ -10375,8 +10580,8 @@ const IA = [
|
|
|
10375
10580
|
name: "tidb",
|
|
10376
10581
|
tokenizerOptions: {
|
|
10377
10582
|
reservedSelect: HA,
|
|
10378
|
-
reservedClauses: [...
|
|
10379
|
-
reservedSetOperations:
|
|
10583
|
+
reservedClauses: [...pA, ...lT, ...hE],
|
|
10584
|
+
reservedSetOperations: BA,
|
|
10380
10585
|
reservedJoins: FA,
|
|
10381
10586
|
reservedKeywordPhrases: YA,
|
|
10382
10587
|
reservedDataTypePhrases: fA,
|
|
@@ -10421,8 +10626,8 @@ const IA = [
|
|
|
10421
10626
|
postProcess: LE
|
|
10422
10627
|
},
|
|
10423
10628
|
formatOptions: {
|
|
10424
|
-
onelineClauses: [...
|
|
10425
|
-
tabularOnelineClauses:
|
|
10629
|
+
onelineClauses: [...lT, ...hE],
|
|
10630
|
+
tabularOnelineClauses: hE
|
|
10426
10631
|
}
|
|
10427
10632
|
}, VA = [
|
|
10428
10633
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
@@ -10654,7 +10859,7 @@ const IA = [
|
|
|
10654
10859
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
10655
10860
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
10656
10861
|
"CAST"
|
|
10657
|
-
],
|
|
10862
|
+
], bA = [
|
|
10658
10863
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
10659
10864
|
"ADVISE",
|
|
10660
10865
|
"ALL",
|
|
@@ -10860,7 +11065,7 @@ const IA = [
|
|
|
10860
11065
|
"WITHIN",
|
|
10861
11066
|
"WORK",
|
|
10862
11067
|
"XOR"
|
|
10863
|
-
],
|
|
11068
|
+
], WA = [
|
|
10864
11069
|
// N1QL does not support any way of declaring types for columns.
|
|
10865
11070
|
// It does not support the CREATE TABLE statement nor the CAST() expression.
|
|
10866
11071
|
//
|
|
@@ -10869,7 +11074,7 @@ const IA = [
|
|
|
10869
11074
|
// which it actually doesn't use.
|
|
10870
11075
|
//
|
|
10871
11076
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
10872
|
-
],
|
|
11077
|
+
], yA = _(["SELECT [ALL | DISTINCT]"]), XA = _([
|
|
10873
11078
|
// queries
|
|
10874
11079
|
"WITH",
|
|
10875
11080
|
"FROM",
|
|
@@ -10896,7 +11101,7 @@ const IA = [
|
|
|
10896
11101
|
"NEST",
|
|
10897
11102
|
"UNNEST",
|
|
10898
11103
|
"RETURNING"
|
|
10899
|
-
]),
|
|
11104
|
+
]), uT = _([
|
|
10900
11105
|
// - update:
|
|
10901
11106
|
"UPDATE",
|
|
10902
11107
|
// - delete:
|
|
@@ -10939,15 +11144,15 @@ const IA = [
|
|
|
10939
11144
|
]), gA = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KA = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), $A = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), wA = _([]), JA = {
|
|
10940
11145
|
name: "n1ql",
|
|
10941
11146
|
tokenizerOptions: {
|
|
10942
|
-
reservedSelect:
|
|
10943
|
-
reservedClauses: [...
|
|
11147
|
+
reservedSelect: yA,
|
|
11148
|
+
reservedClauses: [...XA, ...uT],
|
|
10944
11149
|
reservedSetOperations: gA,
|
|
10945
11150
|
reservedJoins: KA,
|
|
10946
11151
|
reservedKeywordPhrases: $A,
|
|
10947
11152
|
reservedDataTypePhrases: wA,
|
|
10948
11153
|
supportsXor: !0,
|
|
10949
|
-
reservedKeywords:
|
|
10950
|
-
reservedDataTypes:
|
|
11154
|
+
reservedKeywords: bA,
|
|
11155
|
+
reservedDataTypes: WA,
|
|
10951
11156
|
reservedFunctionNames: VA,
|
|
10952
11157
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
10953
11158
|
// but we support them anyway as all other SQL dialects do,
|
|
@@ -10960,7 +11165,7 @@ const IA = [
|
|
|
10960
11165
|
operators: ["%", "==", ":", "||"]
|
|
10961
11166
|
},
|
|
10962
11167
|
formatOptions: {
|
|
10963
|
-
onelineClauses:
|
|
11168
|
+
onelineClauses: uT
|
|
10964
11169
|
}
|
|
10965
11170
|
}, xA = [
|
|
10966
11171
|
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
|
|
@@ -11594,9 +11799,9 @@ const IA = [
|
|
|
11594
11799
|
"UPDATE SET",
|
|
11595
11800
|
// other
|
|
11596
11801
|
"RETURNING"
|
|
11597
|
-
]),
|
|
11802
|
+
]), GT = _([
|
|
11598
11803
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
11599
|
-
]),
|
|
11804
|
+
]), VE = _([
|
|
11600
11805
|
// - create:
|
|
11601
11806
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
11602
11807
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -11640,7 +11845,7 @@ const IA = [
|
|
|
11640
11845
|
name: "plsql",
|
|
11641
11846
|
tokenizerOptions: {
|
|
11642
11847
|
reservedSelect: ZA,
|
|
11643
|
-
reservedClauses: [...qA, ...
|
|
11848
|
+
reservedClauses: [...qA, ...GT, ...VE],
|
|
11644
11849
|
reservedSetOperations: jA,
|
|
11645
11850
|
reservedJoins: kA,
|
|
11646
11851
|
reservedKeywordPhrases: zA,
|
|
@@ -11677,13 +11882,13 @@ const IA = [
|
|
|
11677
11882
|
},
|
|
11678
11883
|
formatOptions: {
|
|
11679
11884
|
alwaysDenseOperators: ["@"],
|
|
11680
|
-
onelineClauses: [...
|
|
11681
|
-
tabularOnelineClauses:
|
|
11885
|
+
onelineClauses: [...GT, ...VE],
|
|
11886
|
+
tabularOnelineClauses: VE
|
|
11682
11887
|
}
|
|
11683
11888
|
};
|
|
11684
11889
|
function eS(T) {
|
|
11685
11890
|
let E = z;
|
|
11686
|
-
return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type:
|
|
11891
|
+
return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type: D.RESERVED_KEYWORD }) : (Re(e.type) && (E = e), e));
|
|
11687
11892
|
}
|
|
11688
11893
|
const RS = [
|
|
11689
11894
|
// https://www.postgresql.org/docs/14/functions.html
|
|
@@ -12526,7 +12731,7 @@ const RS = [
|
|
|
12526
12731
|
"VARCHAR",
|
|
12527
12732
|
"XML",
|
|
12528
12733
|
"ZONE"
|
|
12529
|
-
],
|
|
12734
|
+
], NS = _(["SELECT [ALL | DISTINCT]"]), IS = _([
|
|
12530
12735
|
// queries
|
|
12531
12736
|
"WITH [RECURSIVE]",
|
|
12532
12737
|
"FROM",
|
|
@@ -12549,9 +12754,9 @@ const RS = [
|
|
|
12549
12754
|
"SET",
|
|
12550
12755
|
// other
|
|
12551
12756
|
"RETURNING"
|
|
12552
|
-
]),
|
|
12757
|
+
]), mT = _([
|
|
12553
12758
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
12554
|
-
]),
|
|
12759
|
+
]), bE = _([
|
|
12555
12760
|
// - create
|
|
12556
12761
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
12557
12762
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -12774,11 +12979,11 @@ const RS = [
|
|
|
12774
12979
|
]), rS = _([
|
|
12775
12980
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
12776
12981
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
12777
|
-
]),
|
|
12982
|
+
]), nS = {
|
|
12778
12983
|
name: "postgresql",
|
|
12779
12984
|
tokenizerOptions: {
|
|
12780
|
-
reservedSelect:
|
|
12781
|
-
reservedClauses: [...
|
|
12985
|
+
reservedSelect: NS,
|
|
12986
|
+
reservedClauses: [...IS, ...mT, ...bE],
|
|
12782
12987
|
reservedSetOperations: OS,
|
|
12783
12988
|
reservedJoins: tS,
|
|
12784
12989
|
reservedKeywordPhrases: sS,
|
|
@@ -12897,10 +13102,10 @@ const RS = [
|
|
|
12897
13102
|
},
|
|
12898
13103
|
formatOptions: {
|
|
12899
13104
|
alwaysDenseOperators: ["::", ":"],
|
|
12900
|
-
onelineClauses: [...
|
|
12901
|
-
tabularOnelineClauses:
|
|
13105
|
+
onelineClauses: [...mT, ...bE],
|
|
13106
|
+
tabularOnelineClauses: bE
|
|
12902
13107
|
}
|
|
12903
|
-
},
|
|
13108
|
+
}, CS = [
|
|
12904
13109
|
// https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
|
|
12905
13110
|
"ANY_VALUE",
|
|
12906
13111
|
"APPROXIMATE PERCENTILE_DISC",
|
|
@@ -13474,7 +13679,7 @@ const RS = [
|
|
|
13474
13679
|
"VALUES",
|
|
13475
13680
|
// - update:
|
|
13476
13681
|
"SET"
|
|
13477
|
-
]),
|
|
13682
|
+
]), dT = _([
|
|
13478
13683
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
13479
13684
|
]), WE = _([
|
|
13480
13685
|
// - create:
|
|
@@ -13585,14 +13790,14 @@ const RS = [
|
|
|
13585
13790
|
name: "redshift",
|
|
13586
13791
|
tokenizerOptions: {
|
|
13587
13792
|
reservedSelect: iS,
|
|
13588
|
-
reservedClauses: [...aS, ...
|
|
13793
|
+
reservedClauses: [...aS, ...dT, ...WE],
|
|
13589
13794
|
reservedSetOperations: oS,
|
|
13590
13795
|
reservedJoins: DS,
|
|
13591
13796
|
reservedKeywordPhrases: PS,
|
|
13592
13797
|
reservedDataTypePhrases: MS,
|
|
13593
13798
|
reservedKeywords: LS,
|
|
13594
13799
|
reservedDataTypes: _S,
|
|
13595
|
-
reservedFunctionNames:
|
|
13800
|
+
reservedFunctionNames: CS,
|
|
13596
13801
|
extraParens: ["[]"],
|
|
13597
13802
|
stringTypes: ["''-qq"],
|
|
13598
13803
|
identTypes: ['""-qq'],
|
|
@@ -13616,7 +13821,7 @@ const RS = [
|
|
|
13616
13821
|
},
|
|
13617
13822
|
formatOptions: {
|
|
13618
13823
|
alwaysDenseOperators: ["::"],
|
|
13619
|
-
onelineClauses: [...
|
|
13824
|
+
onelineClauses: [...dT, ...WE],
|
|
13620
13825
|
tabularOnelineClauses: WE
|
|
13621
13826
|
}
|
|
13622
13827
|
}, cS = [
|
|
@@ -14262,7 +14467,7 @@ const RS = [
|
|
|
14262
14467
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
14263
14468
|
"LOAD DATA [LOCAL] INPATH",
|
|
14264
14469
|
"[OVERWRITE] INTO TABLE"
|
|
14265
|
-
]),
|
|
14470
|
+
]), HT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), yE = _([
|
|
14266
14471
|
// - create:
|
|
14267
14472
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
14268
14473
|
// - drop table:
|
|
@@ -14331,20 +14536,20 @@ const RS = [
|
|
|
14331
14536
|
// non-standard-joins
|
|
14332
14537
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
14333
14538
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
14334
|
-
]),
|
|
14539
|
+
]), pS = _([
|
|
14335
14540
|
"ON DELETE",
|
|
14336
14541
|
"ON UPDATE",
|
|
14337
14542
|
"CURRENT ROW",
|
|
14338
14543
|
"{ROWS | RANGE} BETWEEN"
|
|
14339
|
-
]),
|
|
14544
|
+
]), BS = _([]), FS = {
|
|
14340
14545
|
name: "spark",
|
|
14341
14546
|
tokenizerOptions: {
|
|
14342
14547
|
reservedSelect: GS,
|
|
14343
|
-
reservedClauses: [...mS, ...
|
|
14548
|
+
reservedClauses: [...mS, ...HT, ...yE],
|
|
14344
14549
|
reservedSetOperations: dS,
|
|
14345
14550
|
reservedJoins: HS,
|
|
14346
|
-
reservedKeywordPhrases:
|
|
14347
|
-
reservedDataTypePhrases:
|
|
14551
|
+
reservedKeywordPhrases: pS,
|
|
14552
|
+
reservedDataTypePhrases: BS,
|
|
14348
14553
|
supportsXor: !0,
|
|
14349
14554
|
reservedKeywords: cS,
|
|
14350
14555
|
reservedDataTypes: lS,
|
|
@@ -14363,14 +14568,14 @@ const RS = [
|
|
|
14363
14568
|
postProcess: YS
|
|
14364
14569
|
},
|
|
14365
14570
|
formatOptions: {
|
|
14366
|
-
onelineClauses: [...
|
|
14367
|
-
tabularOnelineClauses:
|
|
14571
|
+
onelineClauses: [...HT, ...yE],
|
|
14572
|
+
tabularOnelineClauses: yE
|
|
14368
14573
|
}
|
|
14369
14574
|
};
|
|
14370
14575
|
function YS(T) {
|
|
14371
14576
|
return T.map((E, e) => {
|
|
14372
14577
|
const R = T[e - 1] || z, A = T[e + 1] || z;
|
|
14373
|
-
return x.WINDOW(E) && A.type ===
|
|
14578
|
+
return x.WINDOW(E) && A.type === D.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === D.RESERVED_KEYWORD && !(R.text === "COLLECTION" && A.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
|
|
14374
14579
|
});
|
|
14375
14580
|
}
|
|
14376
14581
|
const fS = [
|
|
@@ -14671,7 +14876,7 @@ const fS = [
|
|
|
14671
14876
|
"TEXT",
|
|
14672
14877
|
"VARCHAR",
|
|
14673
14878
|
"VARYING CHARACTER"
|
|
14674
|
-
],
|
|
14879
|
+
], bS = _(["SELECT [ALL | DISTINCT]"]), WS = _([
|
|
14675
14880
|
// queries
|
|
14676
14881
|
"WITH [RECURSIVE]",
|
|
14677
14882
|
"FROM",
|
|
@@ -14692,7 +14897,7 @@ const fS = [
|
|
|
14692
14897
|
"SET",
|
|
14693
14898
|
// other:
|
|
14694
14899
|
"RETURNING"
|
|
14695
|
-
]),
|
|
14900
|
+
]), pT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), XE = _([
|
|
14696
14901
|
// - create:
|
|
14697
14902
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
14698
14903
|
// - update:
|
|
@@ -14711,7 +14916,7 @@ const fS = [
|
|
|
14711
14916
|
"RENAME TO",
|
|
14712
14917
|
// - set schema
|
|
14713
14918
|
"SET SCHEMA"
|
|
14714
|
-
]),
|
|
14919
|
+
]), yS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), XS = _([
|
|
14715
14920
|
"JOIN",
|
|
14716
14921
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14717
14922
|
"{INNER | CROSS} JOIN",
|
|
@@ -14724,10 +14929,10 @@ const fS = [
|
|
|
14724
14929
|
]), KS = _([]), $S = {
|
|
14725
14930
|
name: "sqlite",
|
|
14726
14931
|
tokenizerOptions: {
|
|
14727
|
-
reservedSelect:
|
|
14728
|
-
reservedClauses: [...
|
|
14729
|
-
reservedSetOperations:
|
|
14730
|
-
reservedJoins:
|
|
14932
|
+
reservedSelect: bS,
|
|
14933
|
+
reservedClauses: [...WS, ...pT, ...XE],
|
|
14934
|
+
reservedSetOperations: yS,
|
|
14935
|
+
reservedJoins: XS,
|
|
14731
14936
|
reservedKeywordPhrases: gS,
|
|
14732
14937
|
reservedDataTypePhrases: KS,
|
|
14733
14938
|
reservedKeywords: hS,
|
|
@@ -14745,7 +14950,7 @@ const fS = [
|
|
|
14745
14950
|
operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
|
|
14746
14951
|
},
|
|
14747
14952
|
formatOptions: {
|
|
14748
|
-
onelineClauses: [...
|
|
14953
|
+
onelineClauses: [...pT, ...XE],
|
|
14749
14954
|
tabularOnelineClauses: XE
|
|
14750
14955
|
}
|
|
14751
14956
|
}, wS = [
|
|
@@ -15102,7 +15307,7 @@ const fS = [
|
|
|
15102
15307
|
"VALUES",
|
|
15103
15308
|
// - update:
|
|
15104
15309
|
"SET"
|
|
15105
|
-
]), BT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]),
|
|
15310
|
+
]), BT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), gE = _([
|
|
15106
15311
|
// - create:
|
|
15107
15312
|
"CREATE [RECURSIVE] VIEW",
|
|
15108
15313
|
// - update:
|
|
@@ -15144,7 +15349,7 @@ const fS = [
|
|
|
15144
15349
|
name: "sql",
|
|
15145
15350
|
tokenizerOptions: {
|
|
15146
15351
|
reservedSelect: vS,
|
|
15147
|
-
reservedClauses: [...QS, ...BT, ...
|
|
15352
|
+
reservedClauses: [...QS, ...BT, ...gE],
|
|
15148
15353
|
reservedSetOperations: ZS,
|
|
15149
15354
|
reservedJoins: qS,
|
|
15150
15355
|
reservedKeywordPhrases: jS,
|
|
@@ -15161,10 +15366,10 @@ const fS = [
|
|
|
15161
15366
|
operators: ["||"]
|
|
15162
15367
|
},
|
|
15163
15368
|
formatOptions: {
|
|
15164
|
-
onelineClauses: [...BT, ...
|
|
15165
|
-
tabularOnelineClauses:
|
|
15369
|
+
onelineClauses: [...BT, ...gE],
|
|
15370
|
+
tabularOnelineClauses: gE
|
|
15166
15371
|
}
|
|
15167
|
-
},
|
|
15372
|
+
}, EN = [
|
|
15168
15373
|
// https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
|
|
15169
15374
|
// rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
|
|
15170
15375
|
// rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
|
|
@@ -15598,7 +15803,7 @@ const fS = [
|
|
|
15598
15803
|
"NEXT",
|
|
15599
15804
|
"PERMUTE",
|
|
15600
15805
|
"PREV"
|
|
15601
|
-
],
|
|
15806
|
+
], TN = [
|
|
15602
15807
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
|
|
15603
15808
|
"ABSENT",
|
|
15604
15809
|
"ADD",
|
|
@@ -15835,7 +16040,7 @@ const fS = [
|
|
|
15835
16040
|
"WRAPPER",
|
|
15836
16041
|
"WRITE",
|
|
15837
16042
|
"ZONE"
|
|
15838
|
-
],
|
|
16043
|
+
], eN = [
|
|
15839
16044
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
|
|
15840
16045
|
// or https://trino.io/docs/current/language/types.html
|
|
15841
16046
|
"BIGINT",
|
|
@@ -15874,7 +16079,7 @@ const fS = [
|
|
|
15874
16079
|
"CODEPOINTS",
|
|
15875
16080
|
"FUNCTION",
|
|
15876
16081
|
"JSONPATH"
|
|
15877
|
-
],
|
|
16082
|
+
], RN = _(["SELECT [ALL | DISTINCT]"]), AN = _([
|
|
15878
16083
|
// queries
|
|
15879
16084
|
"WITH [RECURSIVE]",
|
|
15880
16085
|
"FROM",
|
|
@@ -15902,7 +16107,7 @@ const fS = [
|
|
|
15902
16107
|
"PATTERN",
|
|
15903
16108
|
"SUBSET",
|
|
15904
16109
|
"DEFINE"
|
|
15905
|
-
]),
|
|
16110
|
+
]), FT = _(["CREATE TABLE [IF NOT EXISTS]"]), KE = _([
|
|
15906
16111
|
// - create:
|
|
15907
16112
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
15908
16113
|
// - update:
|
|
@@ -15960,32 +16165,32 @@ const fS = [
|
|
|
15960
16165
|
"SHOW ROLE GRANTS",
|
|
15961
16166
|
"SHOW FUNCTIONS",
|
|
15962
16167
|
"SHOW SESSION"
|
|
15963
|
-
]),
|
|
16168
|
+
]), SN = _([
|
|
15964
16169
|
"UNION [ALL | DISTINCT]",
|
|
15965
16170
|
"EXCEPT [ALL | DISTINCT]",
|
|
15966
16171
|
"INTERSECT [ALL | DISTINCT]"
|
|
15967
|
-
]),
|
|
16172
|
+
]), NN = _([
|
|
15968
16173
|
"JOIN",
|
|
15969
16174
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15970
16175
|
"{INNER | CROSS} JOIN",
|
|
15971
16176
|
"NATURAL [INNER] JOIN",
|
|
15972
16177
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
15973
|
-
]),
|
|
16178
|
+
]), IN = _([
|
|
15974
16179
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
15975
16180
|
// comparison operator
|
|
15976
16181
|
"IS [NOT] DISTINCT FROM"
|
|
15977
|
-
]),
|
|
16182
|
+
]), ON = _([]), tN = {
|
|
15978
16183
|
name: "trino",
|
|
15979
16184
|
tokenizerOptions: {
|
|
15980
|
-
reservedSelect:
|
|
15981
|
-
reservedClauses: [...
|
|
15982
|
-
reservedSetOperations:
|
|
15983
|
-
reservedJoins:
|
|
15984
|
-
reservedKeywordPhrases:
|
|
15985
|
-
reservedDataTypePhrases:
|
|
15986
|
-
reservedKeywords:
|
|
15987
|
-
reservedDataTypes:
|
|
15988
|
-
reservedFunctionNames:
|
|
16185
|
+
reservedSelect: RN,
|
|
16186
|
+
reservedClauses: [...AN, ...FT, ...KE],
|
|
16187
|
+
reservedSetOperations: SN,
|
|
16188
|
+
reservedJoins: NN,
|
|
16189
|
+
reservedKeywordPhrases: IN,
|
|
16190
|
+
reservedDataTypePhrases: ON,
|
|
16191
|
+
reservedKeywords: TN,
|
|
16192
|
+
reservedDataTypes: eN,
|
|
16193
|
+
reservedFunctionNames: EN,
|
|
15989
16194
|
// Trino also supports {- ... -} parenthesis.
|
|
15990
16195
|
// The formatting of these currently works out as a result of { and -
|
|
15991
16196
|
// not getting a space added in-between.
|
|
@@ -16014,10 +16219,10 @@ const fS = [
|
|
|
16014
16219
|
]
|
|
16015
16220
|
},
|
|
16016
16221
|
formatOptions: {
|
|
16017
|
-
onelineClauses: [...
|
|
16018
|
-
tabularOnelineClauses:
|
|
16222
|
+
onelineClauses: [...FT, ...KE],
|
|
16223
|
+
tabularOnelineClauses: KE
|
|
16019
16224
|
}
|
|
16020
|
-
},
|
|
16225
|
+
}, sN = [
|
|
16021
16226
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
16022
16227
|
// aggregate
|
|
16023
16228
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -16322,7 +16527,7 @@ const fS = [
|
|
|
16322
16527
|
// Shorthand functions to use in place of CASE expression
|
|
16323
16528
|
"COALESCE",
|
|
16324
16529
|
"NULLIF"
|
|
16325
|
-
],
|
|
16530
|
+
], rN = [
|
|
16326
16531
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
16327
16532
|
// standard
|
|
16328
16533
|
"ADD",
|
|
@@ -16503,7 +16708,7 @@ const fS = [
|
|
|
16503
16708
|
"WRITETEXT",
|
|
16504
16709
|
// https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver16#action
|
|
16505
16710
|
"$ACTION"
|
|
16506
|
-
],
|
|
16711
|
+
], nN = [
|
|
16507
16712
|
// https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15
|
|
16508
16713
|
"BINARY",
|
|
16509
16714
|
"BIT",
|
|
@@ -16530,7 +16735,7 @@ const fS = [
|
|
|
16530
16735
|
"TIMESTAMP",
|
|
16531
16736
|
"VARBINARY",
|
|
16532
16737
|
"VARCHAR"
|
|
16533
|
-
],
|
|
16738
|
+
], CN = _(["SELECT [ALL | DISTINCT]"]), LN = _([
|
|
16534
16739
|
// queries
|
|
16535
16740
|
"WITH",
|
|
16536
16741
|
"INTO",
|
|
@@ -16555,7 +16760,7 @@ const fS = [
|
|
|
16555
16760
|
"MERGE [INTO]",
|
|
16556
16761
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
16557
16762
|
"UPDATE SET"
|
|
16558
|
-
]),
|
|
16763
|
+
]), YT = _(["CREATE TABLE"]), $E = _([
|
|
16559
16764
|
// - create:
|
|
16560
16765
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
16561
16766
|
// - update:
|
|
@@ -16735,27 +16940,27 @@ const fS = [
|
|
|
16735
16940
|
"XACT_ABORT",
|
|
16736
16941
|
"XML INDEX",
|
|
16737
16942
|
"XML SCHEMA COLLECTION"
|
|
16738
|
-
]),
|
|
16943
|
+
]), _N = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), iN = _([
|
|
16739
16944
|
"JOIN",
|
|
16740
16945
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16741
16946
|
"{INNER | CROSS} JOIN",
|
|
16742
16947
|
// non-standard joins
|
|
16743
16948
|
"{CROSS | OUTER} APPLY"
|
|
16744
|
-
]),
|
|
16949
|
+
]), aN = _([
|
|
16745
16950
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
16746
16951
|
"{ROWS | RANGE} BETWEEN"
|
|
16747
|
-
]),
|
|
16952
|
+
]), oN = _([]), DN = {
|
|
16748
16953
|
name: "transactsql",
|
|
16749
16954
|
tokenizerOptions: {
|
|
16750
|
-
reservedSelect:
|
|
16751
|
-
reservedClauses: [...
|
|
16752
|
-
reservedSetOperations:
|
|
16753
|
-
reservedJoins:
|
|
16754
|
-
reservedKeywordPhrases:
|
|
16755
|
-
reservedDataTypePhrases:
|
|
16756
|
-
reservedKeywords:
|
|
16757
|
-
reservedDataTypes:
|
|
16758
|
-
reservedFunctionNames:
|
|
16955
|
+
reservedSelect: CN,
|
|
16956
|
+
reservedClauses: [...LN, ...YT, ...$E],
|
|
16957
|
+
reservedSetOperations: _N,
|
|
16958
|
+
reservedJoins: iN,
|
|
16959
|
+
reservedKeywordPhrases: aN,
|
|
16960
|
+
reservedDataTypePhrases: oN,
|
|
16961
|
+
reservedKeywords: rN,
|
|
16962
|
+
reservedDataTypes: nN,
|
|
16963
|
+
reservedFunctionNames: sN,
|
|
16759
16964
|
nestedBlockComments: !0,
|
|
16760
16965
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
16761
16966
|
identTypes: ['""-qq', "[]"],
|
|
@@ -16785,10 +16990,10 @@ const fS = [
|
|
|
16785
16990
|
},
|
|
16786
16991
|
formatOptions: {
|
|
16787
16992
|
alwaysDenseOperators: ["::"],
|
|
16788
|
-
onelineClauses: [...
|
|
16789
|
-
tabularOnelineClauses:
|
|
16993
|
+
onelineClauses: [...YT, ...$E],
|
|
16994
|
+
tabularOnelineClauses: $E
|
|
16790
16995
|
}
|
|
16791
|
-
},
|
|
16996
|
+
}, PN = [
|
|
16792
16997
|
// List of all keywords taken from:
|
|
16793
16998
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
|
|
16794
16999
|
// Then filtered down to reserved keywords by running
|
|
@@ -17001,7 +17206,7 @@ const fS = [
|
|
|
17001
17206
|
"XOR",
|
|
17002
17207
|
"YEAR_MONTH",
|
|
17003
17208
|
"ZEROFILL"
|
|
17004
|
-
],
|
|
17209
|
+
], MN = [
|
|
17005
17210
|
// https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
|
|
17006
17211
|
"BIGINT",
|
|
17007
17212
|
"BINARY",
|
|
@@ -17050,7 +17255,7 @@ const fS = [
|
|
|
17050
17255
|
"VARCHAR",
|
|
17051
17256
|
"VARCHARACTER",
|
|
17052
17257
|
"YEAR"
|
|
17053
|
-
],
|
|
17258
|
+
], UN = [
|
|
17054
17259
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
|
|
17055
17260
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
|
|
17056
17261
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
|
|
@@ -17330,7 +17535,7 @@ const fS = [
|
|
|
17330
17535
|
"WEEKDAY",
|
|
17331
17536
|
"WEEKOFYEAR",
|
|
17332
17537
|
"YEAR"
|
|
17333
|
-
],
|
|
17538
|
+
], cN = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lN = _([
|
|
17334
17539
|
// queries
|
|
17335
17540
|
"WITH",
|
|
17336
17541
|
"FROM",
|
|
@@ -17352,9 +17557,9 @@ const fS = [
|
|
|
17352
17557
|
// Data definition
|
|
17353
17558
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
17354
17559
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
17355
|
-
]),
|
|
17560
|
+
]), fT = _([
|
|
17356
17561
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
17357
|
-
]),
|
|
17562
|
+
]), wE = _([
|
|
17358
17563
|
// - create:
|
|
17359
17564
|
"CREATE VIEW",
|
|
17360
17565
|
// - update:
|
|
@@ -17531,36 +17736,36 @@ const fS = [
|
|
|
17531
17736
|
"REPEAT",
|
|
17532
17737
|
"RETURN",
|
|
17533
17738
|
"WHILE"
|
|
17534
|
-
]),
|
|
17739
|
+
]), uN = _([
|
|
17535
17740
|
"UNION [ALL | DISTINCT]",
|
|
17536
17741
|
"EXCEPT",
|
|
17537
17742
|
"INTERSECT",
|
|
17538
17743
|
"MINUS"
|
|
17539
|
-
]),
|
|
17744
|
+
]), GN = _([
|
|
17540
17745
|
"JOIN",
|
|
17541
17746
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17542
17747
|
"{INNER | CROSS} JOIN",
|
|
17543
17748
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
17544
17749
|
// non-standard joins
|
|
17545
17750
|
"STRAIGHT_JOIN"
|
|
17546
|
-
]),
|
|
17751
|
+
]), mN = _([
|
|
17547
17752
|
"ON DELETE",
|
|
17548
17753
|
"ON UPDATE",
|
|
17549
17754
|
"CHARACTER SET",
|
|
17550
17755
|
"{ROWS | RANGE} BETWEEN",
|
|
17551
17756
|
"IDENTIFIED BY"
|
|
17552
|
-
]),
|
|
17757
|
+
]), dN = _([]), HN = {
|
|
17553
17758
|
name: "singlestoredb",
|
|
17554
17759
|
tokenizerOptions: {
|
|
17555
|
-
reservedSelect:
|
|
17556
|
-
reservedClauses: [...
|
|
17557
|
-
reservedSetOperations:
|
|
17558
|
-
reservedJoins:
|
|
17559
|
-
reservedKeywordPhrases:
|
|
17560
|
-
reservedDataTypePhrases:
|
|
17561
|
-
reservedKeywords:
|
|
17562
|
-
reservedDataTypes:
|
|
17563
|
-
reservedFunctionNames:
|
|
17760
|
+
reservedSelect: cN,
|
|
17761
|
+
reservedClauses: [...lN, ...fT, ...wE],
|
|
17762
|
+
reservedSetOperations: uN,
|
|
17763
|
+
reservedJoins: GN,
|
|
17764
|
+
reservedKeywordPhrases: mN,
|
|
17765
|
+
reservedDataTypePhrases: dN,
|
|
17766
|
+
reservedKeywords: PN,
|
|
17767
|
+
reservedDataTypes: MN,
|
|
17768
|
+
reservedFunctionNames: UN,
|
|
17564
17769
|
// TODO: support _binary"some string" prefix
|
|
17565
17770
|
stringTypes: [
|
|
17566
17771
|
'""-qq-bs',
|
|
@@ -17597,10 +17802,10 @@ const fS = [
|
|
|
17597
17802
|
},
|
|
17598
17803
|
formatOptions: {
|
|
17599
17804
|
alwaysDenseOperators: ["::", "::$", "::%"],
|
|
17600
|
-
onelineClauses: [...
|
|
17601
|
-
tabularOnelineClauses:
|
|
17805
|
+
onelineClauses: [...fT, ...wE],
|
|
17806
|
+
tabularOnelineClauses: wE
|
|
17602
17807
|
}
|
|
17603
|
-
},
|
|
17808
|
+
}, pN = [
|
|
17604
17809
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
17605
17810
|
//
|
|
17606
17811
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -18208,7 +18413,7 @@ const fS = [
|
|
|
18208
18413
|
"QUARTER",
|
|
18209
18414
|
"ZEROIFNULL",
|
|
18210
18415
|
"ZIPF"
|
|
18211
|
-
],
|
|
18416
|
+
], BN = [
|
|
18212
18417
|
// https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
|
|
18213
18418
|
//
|
|
18214
18419
|
// run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
|
|
@@ -18305,7 +18510,7 @@ const fS = [
|
|
|
18305
18510
|
"WITH",
|
|
18306
18511
|
// These are definitely keywords, but haven't found a definite list in the docs
|
|
18307
18512
|
"COMMENT"
|
|
18308
|
-
],
|
|
18513
|
+
], FN = [
|
|
18309
18514
|
"NUMBER",
|
|
18310
18515
|
"DECIMAL",
|
|
18311
18516
|
"NUMERIC",
|
|
@@ -18342,7 +18547,7 @@ const fS = [
|
|
|
18342
18547
|
"ARRAY",
|
|
18343
18548
|
"GEOGRAPHY",
|
|
18344
18549
|
"GEOMETRY"
|
|
18345
|
-
],
|
|
18550
|
+
], YN = _(["SELECT [ALL | DISTINCT]"]), fN = _([
|
|
18346
18551
|
// queries
|
|
18347
18552
|
"WITH [RECURSIVE]",
|
|
18348
18553
|
"FROM",
|
|
@@ -18370,10 +18575,10 @@ const fS = [
|
|
|
18370
18575
|
"WHEN MATCHED [AND]",
|
|
18371
18576
|
"THEN {UPDATE SET | DELETE}",
|
|
18372
18577
|
"WHEN NOT MATCHED THEN INSERT"
|
|
18373
|
-
]),
|
|
18578
|
+
]), hT = _([
|
|
18374
18579
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
18375
18580
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
18376
|
-
]),
|
|
18581
|
+
]), JE = _([
|
|
18377
18582
|
// - create:
|
|
18378
18583
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
18379
18584
|
// - update:
|
|
@@ -18614,25 +18819,25 @@ const fS = [
|
|
|
18614
18819
|
"USE SCHEMA",
|
|
18615
18820
|
"USE SECONDARY ROLES",
|
|
18616
18821
|
"USE WAREHOUSE"
|
|
18617
|
-
]),
|
|
18822
|
+
]), hN = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), VN = _([
|
|
18618
18823
|
"[INNER] JOIN",
|
|
18619
18824
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
18620
18825
|
"{CROSS | NATURAL} JOIN"
|
|
18621
|
-
]),
|
|
18826
|
+
]), bN = _([
|
|
18622
18827
|
"{ROWS | RANGE} BETWEEN",
|
|
18623
18828
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
18624
|
-
]),
|
|
18829
|
+
]), WN = _([]), yN = {
|
|
18625
18830
|
name: "snowflake",
|
|
18626
18831
|
tokenizerOptions: {
|
|
18627
|
-
reservedSelect:
|
|
18628
|
-
reservedClauses: [...
|
|
18629
|
-
reservedSetOperations:
|
|
18630
|
-
reservedJoins:
|
|
18631
|
-
reservedKeywordPhrases:
|
|
18632
|
-
reservedDataTypePhrases:
|
|
18633
|
-
reservedKeywords:
|
|
18634
|
-
reservedDataTypes:
|
|
18635
|
-
reservedFunctionNames:
|
|
18832
|
+
reservedSelect: YN,
|
|
18833
|
+
reservedClauses: [...fN, ...hT, ...JE],
|
|
18834
|
+
reservedSetOperations: hN,
|
|
18835
|
+
reservedJoins: VN,
|
|
18836
|
+
reservedKeywordPhrases: bN,
|
|
18837
|
+
reservedDataTypePhrases: WN,
|
|
18838
|
+
reservedKeywords: BN,
|
|
18839
|
+
reservedDataTypes: FN,
|
|
18840
|
+
reservedFunctionNames: pN,
|
|
18636
18841
|
stringTypes: ["$$", "''-qq-bs"],
|
|
18637
18842
|
identTypes: ['""-qq'],
|
|
18638
18843
|
variableTypes: [
|
|
@@ -18662,54 +18867,54 @@ const fS = [
|
|
|
18662
18867
|
},
|
|
18663
18868
|
formatOptions: {
|
|
18664
18869
|
alwaysDenseOperators: ["::"],
|
|
18665
|
-
onelineClauses: [...
|
|
18666
|
-
tabularOnelineClauses:
|
|
18870
|
+
onelineClauses: [...hT, ...JE],
|
|
18871
|
+
tabularOnelineClauses: JE
|
|
18667
18872
|
}
|
|
18668
|
-
},
|
|
18873
|
+
}, XN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
18669
18874
|
__proto__: null,
|
|
18670
18875
|
bigquery: _R,
|
|
18671
18876
|
db2: HR,
|
|
18672
|
-
db2i:
|
|
18877
|
+
db2i: yR,
|
|
18673
18878
|
duckdb: ZR,
|
|
18674
18879
|
hive: SA,
|
|
18675
18880
|
mariadb: _A,
|
|
18676
18881
|
mysql: uA,
|
|
18677
18882
|
n1ql: JA,
|
|
18678
18883
|
plsql: TS,
|
|
18679
|
-
postgresql:
|
|
18884
|
+
postgresql: nS,
|
|
18680
18885
|
redshift: US,
|
|
18681
|
-
singlestoredb:
|
|
18682
|
-
snowflake:
|
|
18886
|
+
singlestoredb: HN,
|
|
18887
|
+
snowflake: yN,
|
|
18683
18888
|
spark: FS,
|
|
18684
18889
|
sql: zS,
|
|
18685
18890
|
sqlite: $S,
|
|
18686
18891
|
tidb: hA,
|
|
18687
|
-
transactsql:
|
|
18688
|
-
trino:
|
|
18689
|
-
}, Symbol.toStringTag, { value: "Module" })), eE = (T) => T[T.length - 1],
|
|
18892
|
+
transactsql: DN,
|
|
18893
|
+
trino: tN
|
|
18894
|
+
}, Symbol.toStringTag, { value: "Module" })), eE = (T) => T[T.length - 1], Ae = (T) => T.sort((E, e) => e.length - E.length || E.localeCompare(e)), IE = (T) => T.replace(/\s+/gu, " "), xE = (T) => /\n/.test(T), X = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), VT = /\s+/uy, v = (T) => new RegExp(`(?:${T})`, "uy"), gN = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), KN = (T) => T + "(?:-" + T + ")*", $N = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(gN).join("|")}${E ? "" : "|"})`, wN = (T) => new RegExp(`(?:${T.map(X).join("|")}).*?(?=\r
|
|
18690
18895
|
|\r|
|
|
18691
|
-
|$)`, "uy"),
|
|
18896
|
+
|$)`, "uy"), bT = (T, E = []) => {
|
|
18692
18897
|
const e = T === "open" ? 0 : 1, R = ["()", ...E].map((A) => A[e]);
|
|
18693
|
-
return v(R.map(
|
|
18694
|
-
}, WT = (T) => v(`${
|
|
18898
|
+
return v(R.map(X).join("|"));
|
|
18899
|
+
}, WT = (T) => v(`${Ae(T).map(X).join("|")}`), JN = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", K = (T, E = {}) => {
|
|
18695
18900
|
if (T.length === 0)
|
|
18696
18901
|
return /^\b$/u;
|
|
18697
|
-
const e =
|
|
18902
|
+
const e = JN(E), R = Ae(T).map(X).join("|").replace(/ /gu, "\\s+");
|
|
18698
18903
|
return new RegExp(`(?:${R})${e}\\b`, "iuy");
|
|
18699
|
-
},
|
|
18904
|
+
}, vE = (T, E) => {
|
|
18700
18905
|
if (!T.length)
|
|
18701
18906
|
return;
|
|
18702
|
-
const e = T.map(
|
|
18907
|
+
const e = T.map(X).join("|");
|
|
18703
18908
|
return v(`(?:${e})(?:${E})`);
|
|
18704
|
-
},
|
|
18909
|
+
}, xN = () => {
|
|
18705
18910
|
const T = {
|
|
18706
18911
|
"<": ">",
|
|
18707
18912
|
"[": "]",
|
|
18708
18913
|
"(": ")",
|
|
18709
18914
|
"{": "}"
|
|
18710
|
-
}, E = "{left}(?:(?!{right}').)*?{right}", e = Object.entries(T).map(([I, t]) => E.replace(/{left}/g,
|
|
18915
|
+
}, E = "{left}(?:(?!{right}').)*?{right}", e = Object.entries(T).map(([I, t]) => E.replace(/{left}/g, X(I)).replace(/{right}/g, X(t))), R = X(Object.keys(T).join(""));
|
|
18711
18916
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${R}])(?:(?!\k<tag>').)*?\k<tag>`}|${e.join("|")})'`;
|
|
18712
|
-
},
|
|
18917
|
+
}, yT = {
|
|
18713
18918
|
// - backtick quoted (using `` to escape)
|
|
18714
18919
|
"``": "(?:`[^`]*`)+",
|
|
18715
18920
|
// - Transact-SQL square bracket quoted (using ]] to escape)
|
|
@@ -18733,16 +18938,16 @@ const fS = [
|
|
|
18733
18938
|
// Hive and Spark variables: ${name}
|
|
18734
18939
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
18735
18940
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
18736
|
-
"q''":
|
|
18737
|
-
},
|
|
18738
|
-
const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I =
|
|
18739
|
-
return e ?
|
|
18941
|
+
"q''": xN()
|
|
18942
|
+
}, Se = (T) => typeof T == "string" ? yT[T] : "regex" in T ? T.regex : $N(T) + yT[T.quote], vN = (T) => v(T.map((E) => "regex" in E ? E.regex : Se(E)).join("|")), Ne = (T) => T.map(Se).join("|"), XT = (T) => v(Ne(T)), QN = (T = {}) => v(Ie(T)), Ie = ({ first: T, rest: E, dashes: e, allowFirstCharNumber: R } = {}) => {
|
|
18943
|
+
const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I = X(T ?? ""), t = X(E ?? ""), s = R ? `[${A}${S}${I}][${A}${S}${t}]*` : `[${A}${I}][${A}${S}${t}]*`;
|
|
18944
|
+
return e ? KN(s) : s;
|
|
18740
18945
|
};
|
|
18741
|
-
function
|
|
18946
|
+
function Oe(T, E) {
|
|
18742
18947
|
const e = T.slice(0, E).split(/\n/);
|
|
18743
18948
|
return { line: e.length, col: e[e.length - 1].length + 1 };
|
|
18744
18949
|
}
|
|
18745
|
-
class
|
|
18950
|
+
class ZN {
|
|
18746
18951
|
constructor(E, e) {
|
|
18747
18952
|
this.rules = E, this.dialectName = e, this.input = "", this.index = 0;
|
|
18748
18953
|
}
|
|
@@ -18768,7 +18973,7 @@ class ZI {
|
|
|
18768
18973
|
return e;
|
|
18769
18974
|
}
|
|
18770
18975
|
createParseError() {
|
|
18771
|
-
const E = this.input.slice(this.index, this.index + 10), { line: e, col: R } =
|
|
18976
|
+
const E = this.input.slice(this.index, this.index + 10), { line: e, col: R } = Oe(this.input, this.index);
|
|
18772
18977
|
return new Error(`Parse error: Unexpected "${E}" at line ${e} column ${R}.
|
|
18773
18978
|
${this.dialectInfo()}`);
|
|
18774
18979
|
}
|
|
@@ -18777,8 +18982,8 @@ ${this.dialectInfo()}`);
|
|
|
18777
18982
|
If possible, please select a more specific dialect (like sqlite, postgresql, etc).` : `SQL dialect used: "${this.dialectName}".`;
|
|
18778
18983
|
}
|
|
18779
18984
|
getWhitespace() {
|
|
18780
|
-
|
|
18781
|
-
const E =
|
|
18985
|
+
VT.lastIndex = this.index;
|
|
18986
|
+
const E = VT.exec(this.input);
|
|
18782
18987
|
if (E)
|
|
18783
18988
|
return this.index += E[0].length, E[0];
|
|
18784
18989
|
}
|
|
@@ -18804,23 +19009,23 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
|
|
|
18804
19009
|
}
|
|
18805
19010
|
}
|
|
18806
19011
|
}
|
|
18807
|
-
const
|
|
18808
|
-
class
|
|
19012
|
+
const gT = /\/\*/uy, qN = /[\s\S]/uy, jN = /\*\//uy;
|
|
19013
|
+
class kN {
|
|
18809
19014
|
constructor() {
|
|
18810
19015
|
this.lastIndex = 0;
|
|
18811
19016
|
}
|
|
18812
19017
|
exec(E) {
|
|
18813
19018
|
let e = "", R, A = 0;
|
|
18814
|
-
if (R = this.matchSection(
|
|
19019
|
+
if (R = this.matchSection(gT, E))
|
|
18815
19020
|
e += R, A++;
|
|
18816
19021
|
else
|
|
18817
19022
|
return null;
|
|
18818
19023
|
for (; A > 0; )
|
|
18819
|
-
if (R = this.matchSection(
|
|
19024
|
+
if (R = this.matchSection(gT, E))
|
|
18820
19025
|
e += R, A++;
|
|
18821
|
-
else if (R = this.matchSection(
|
|
19026
|
+
else if (R = this.matchSection(jN, E))
|
|
18822
19027
|
e += R, A--;
|
|
18823
|
-
else if (R = this.matchSection(
|
|
19028
|
+
else if (R = this.matchSection(qN, E))
|
|
18824
19029
|
e += R;
|
|
18825
19030
|
else
|
|
18826
19031
|
return null;
|
|
@@ -18832,7 +19037,7 @@ class kI {
|
|
|
18832
19037
|
return R && (this.lastIndex += R[0].length), R ? R[0] : null;
|
|
18833
19038
|
}
|
|
18834
19039
|
}
|
|
18835
|
-
class
|
|
19040
|
+
class zN {
|
|
18836
19041
|
constructor(E, e) {
|
|
18837
19042
|
this.cfg = E, this.dialectName = e, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
|
|
18838
19043
|
}
|
|
@@ -18841,7 +19046,7 @@ class zI {
|
|
|
18841
19046
|
...this.rulesBeforeParams,
|
|
18842
19047
|
...this.buildParamRules(this.cfg, e),
|
|
18843
19048
|
...this.rulesAfterParams
|
|
18844
|
-
], A = new
|
|
19049
|
+
], A = new ZN(R, this.dialectName).tokenize(E);
|
|
18845
19050
|
return this.cfg.postProcess ? this.cfg.postProcess(A) : A;
|
|
18846
19051
|
}
|
|
18847
19052
|
// These rules can be cached as they only depend on
|
|
@@ -18850,127 +19055,127 @@ class zI {
|
|
|
18850
19055
|
var e, R, A;
|
|
18851
19056
|
return this.validRules([
|
|
18852
19057
|
{
|
|
18853
|
-
type:
|
|
19058
|
+
type: D.DISABLE_COMMENT,
|
|
18854
19059
|
regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
|
|
18855
19060
|
},
|
|
18856
19061
|
{
|
|
18857
|
-
type:
|
|
18858
|
-
regex: E.nestedBlockComments ? new
|
|
19062
|
+
type: D.BLOCK_COMMENT,
|
|
19063
|
+
regex: E.nestedBlockComments ? new kN() : /(\/\*[^]*?\*\/)/uy
|
|
18859
19064
|
},
|
|
18860
19065
|
{
|
|
18861
|
-
type:
|
|
18862
|
-
regex:
|
|
19066
|
+
type: D.LINE_COMMENT,
|
|
19067
|
+
regex: wN((e = E.lineCommentTypes) !== null && e !== void 0 ? e : ["--"])
|
|
18863
19068
|
},
|
|
18864
19069
|
{
|
|
18865
|
-
type:
|
|
19070
|
+
type: D.QUOTED_IDENTIFIER,
|
|
18866
19071
|
regex: XT(E.identTypes)
|
|
18867
19072
|
},
|
|
18868
19073
|
{
|
|
18869
|
-
type:
|
|
19074
|
+
type: D.NUMBER,
|
|
18870
19075
|
regex: E.underscoresInNumbers ? /(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy : /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
|
|
18871
19076
|
},
|
|
18872
19077
|
// RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
|
|
18873
19078
|
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
18874
19079
|
{
|
|
18875
|
-
type:
|
|
19080
|
+
type: D.RESERVED_KEYWORD_PHRASE,
|
|
18876
19081
|
regex: K((R = E.reservedKeywordPhrases) !== null && R !== void 0 ? R : [], E.identChars),
|
|
18877
|
-
text:
|
|
19082
|
+
text: B
|
|
18878
19083
|
},
|
|
18879
19084
|
{
|
|
18880
|
-
type:
|
|
19085
|
+
type: D.RESERVED_DATA_TYPE_PHRASE,
|
|
18881
19086
|
regex: K((A = E.reservedDataTypePhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
18882
|
-
text:
|
|
19087
|
+
text: B
|
|
18883
19088
|
},
|
|
18884
19089
|
{
|
|
18885
|
-
type:
|
|
19090
|
+
type: D.CASE,
|
|
18886
19091
|
regex: /CASE\b/iuy,
|
|
18887
|
-
text:
|
|
19092
|
+
text: B
|
|
18888
19093
|
},
|
|
18889
19094
|
{
|
|
18890
|
-
type:
|
|
19095
|
+
type: D.END,
|
|
18891
19096
|
regex: /END\b/iuy,
|
|
18892
|
-
text:
|
|
19097
|
+
text: B
|
|
18893
19098
|
},
|
|
18894
19099
|
{
|
|
18895
|
-
type:
|
|
19100
|
+
type: D.BETWEEN,
|
|
18896
19101
|
regex: /BETWEEN\b/iuy,
|
|
18897
|
-
text:
|
|
19102
|
+
text: B
|
|
18898
19103
|
},
|
|
18899
19104
|
{
|
|
18900
|
-
type:
|
|
19105
|
+
type: D.LIMIT,
|
|
18901
19106
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
18902
|
-
text:
|
|
19107
|
+
text: B
|
|
18903
19108
|
},
|
|
18904
19109
|
{
|
|
18905
|
-
type:
|
|
19110
|
+
type: D.RESERVED_CLAUSE,
|
|
18906
19111
|
regex: K(E.reservedClauses, E.identChars),
|
|
18907
|
-
text:
|
|
19112
|
+
text: B
|
|
18908
19113
|
},
|
|
18909
19114
|
{
|
|
18910
|
-
type:
|
|
19115
|
+
type: D.RESERVED_SELECT,
|
|
18911
19116
|
regex: K(E.reservedSelect, E.identChars),
|
|
18912
|
-
text:
|
|
19117
|
+
text: B
|
|
18913
19118
|
},
|
|
18914
19119
|
{
|
|
18915
|
-
type:
|
|
19120
|
+
type: D.RESERVED_SET_OPERATION,
|
|
18916
19121
|
regex: K(E.reservedSetOperations, E.identChars),
|
|
18917
|
-
text:
|
|
19122
|
+
text: B
|
|
18918
19123
|
},
|
|
18919
19124
|
{
|
|
18920
|
-
type:
|
|
19125
|
+
type: D.WHEN,
|
|
18921
19126
|
regex: /WHEN\b/iuy,
|
|
18922
|
-
text:
|
|
19127
|
+
text: B
|
|
18923
19128
|
},
|
|
18924
19129
|
{
|
|
18925
|
-
type:
|
|
19130
|
+
type: D.ELSE,
|
|
18926
19131
|
regex: /ELSE\b/iuy,
|
|
18927
|
-
text:
|
|
19132
|
+
text: B
|
|
18928
19133
|
},
|
|
18929
19134
|
{
|
|
18930
|
-
type:
|
|
19135
|
+
type: D.THEN,
|
|
18931
19136
|
regex: /THEN\b/iuy,
|
|
18932
|
-
text:
|
|
19137
|
+
text: B
|
|
18933
19138
|
},
|
|
18934
19139
|
{
|
|
18935
|
-
type:
|
|
19140
|
+
type: D.RESERVED_JOIN,
|
|
18936
19141
|
regex: K(E.reservedJoins, E.identChars),
|
|
18937
|
-
text:
|
|
19142
|
+
text: B
|
|
18938
19143
|
},
|
|
18939
19144
|
{
|
|
18940
|
-
type:
|
|
19145
|
+
type: D.AND,
|
|
18941
19146
|
regex: /AND\b/iuy,
|
|
18942
|
-
text:
|
|
19147
|
+
text: B
|
|
18943
19148
|
},
|
|
18944
19149
|
{
|
|
18945
|
-
type:
|
|
19150
|
+
type: D.OR,
|
|
18946
19151
|
regex: /OR\b/iuy,
|
|
18947
|
-
text:
|
|
19152
|
+
text: B
|
|
18948
19153
|
},
|
|
18949
19154
|
{
|
|
18950
|
-
type:
|
|
19155
|
+
type: D.XOR,
|
|
18951
19156
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
18952
|
-
text:
|
|
19157
|
+
text: B
|
|
18953
19158
|
},
|
|
18954
19159
|
...E.operatorKeyword ? [
|
|
18955
19160
|
{
|
|
18956
|
-
type:
|
|
19161
|
+
type: D.OPERATOR,
|
|
18957
19162
|
regex: /OPERATOR *\([^)]+\)/iuy
|
|
18958
19163
|
}
|
|
18959
19164
|
] : [],
|
|
18960
19165
|
{
|
|
18961
|
-
type:
|
|
19166
|
+
type: D.RESERVED_FUNCTION_NAME,
|
|
18962
19167
|
regex: K(E.reservedFunctionNames, E.identChars),
|
|
18963
|
-
text:
|
|
19168
|
+
text: B
|
|
18964
19169
|
},
|
|
18965
19170
|
{
|
|
18966
|
-
type:
|
|
19171
|
+
type: D.RESERVED_DATA_TYPE,
|
|
18967
19172
|
regex: K(E.reservedDataTypes, E.identChars),
|
|
18968
|
-
text:
|
|
19173
|
+
text: B
|
|
18969
19174
|
},
|
|
18970
19175
|
{
|
|
18971
|
-
type:
|
|
19176
|
+
type: D.RESERVED_KEYWORD,
|
|
18972
19177
|
regex: K(E.reservedKeywords, E.identChars),
|
|
18973
|
-
text:
|
|
19178
|
+
text: B
|
|
18974
19179
|
}
|
|
18975
19180
|
]);
|
|
18976
19181
|
}
|
|
@@ -18980,26 +19185,26 @@ class zI {
|
|
|
18980
19185
|
var e, R;
|
|
18981
19186
|
return this.validRules([
|
|
18982
19187
|
{
|
|
18983
|
-
type:
|
|
18984
|
-
regex: E.variableTypes ?
|
|
19188
|
+
type: D.VARIABLE,
|
|
19189
|
+
regex: E.variableTypes ? vN(E.variableTypes) : void 0
|
|
18985
19190
|
},
|
|
18986
|
-
{ type:
|
|
19191
|
+
{ type: D.STRING, regex: XT(E.stringTypes) },
|
|
18987
19192
|
{
|
|
18988
|
-
type:
|
|
18989
|
-
regex:
|
|
19193
|
+
type: D.IDENTIFIER,
|
|
19194
|
+
regex: QN(E.identChars)
|
|
18990
19195
|
},
|
|
18991
|
-
{ type:
|
|
18992
|
-
{ type:
|
|
19196
|
+
{ type: D.DELIMITER, regex: /[;]/uy },
|
|
19197
|
+
{ type: D.COMMA, regex: /[,]/y },
|
|
18993
19198
|
{
|
|
18994
|
-
type:
|
|
18995
|
-
regex:
|
|
19199
|
+
type: D.OPEN_PAREN,
|
|
19200
|
+
regex: bT("open", E.extraParens)
|
|
18996
19201
|
},
|
|
18997
19202
|
{
|
|
18998
|
-
type:
|
|
18999
|
-
regex:
|
|
19203
|
+
type: D.CLOSE_PAREN,
|
|
19204
|
+
regex: bT("close", E.extraParens)
|
|
19000
19205
|
},
|
|
19001
19206
|
{
|
|
19002
|
-
type:
|
|
19207
|
+
type: D.OPERATOR,
|
|
19003
19208
|
regex: WT([
|
|
19004
19209
|
// standard operators
|
|
19005
19210
|
"+",
|
|
@@ -19015,9 +19220,9 @@ class zI {
|
|
|
19015
19220
|
...(e = E.operators) !== null && e !== void 0 ? e : []
|
|
19016
19221
|
])
|
|
19017
19222
|
},
|
|
19018
|
-
{ type:
|
|
19223
|
+
{ type: D.ASTERISK, regex: /[*]/uy },
|
|
19019
19224
|
{
|
|
19020
|
-
type:
|
|
19225
|
+
type: D.PROPERTY_ACCESS_OPERATOR,
|
|
19021
19226
|
regex: WT([".", ...(R = E.propertyAccessOperators) !== null && R !== void 0 ? R : []])
|
|
19022
19227
|
}
|
|
19023
19228
|
]);
|
|
@@ -19035,31 +19240,31 @@ class zI {
|
|
|
19035
19240
|
};
|
|
19036
19241
|
return this.validRules([
|
|
19037
19242
|
{
|
|
19038
|
-
type:
|
|
19039
|
-
regex:
|
|
19243
|
+
type: D.NAMED_PARAMETER,
|
|
19244
|
+
regex: vE(s.named, Ie(E.paramChars || E.identChars)),
|
|
19040
19245
|
key: (O) => O.slice(1)
|
|
19041
19246
|
},
|
|
19042
19247
|
{
|
|
19043
|
-
type:
|
|
19044
|
-
regex:
|
|
19045
|
-
key: (O) => (({ tokenKey: N, quoteChar: r }) => N.replace(new RegExp(
|
|
19248
|
+
type: D.QUOTED_PARAMETER,
|
|
19249
|
+
regex: vE(s.quoted, Ne(E.identTypes)),
|
|
19250
|
+
key: (O) => (({ tokenKey: N, quoteChar: r }) => N.replace(new RegExp(X("\\" + r), "gu"), r))({
|
|
19046
19251
|
tokenKey: O.slice(2, -1),
|
|
19047
19252
|
quoteChar: O.slice(-1)
|
|
19048
19253
|
})
|
|
19049
19254
|
},
|
|
19050
19255
|
{
|
|
19051
|
-
type:
|
|
19052
|
-
regex:
|
|
19256
|
+
type: D.NUMBERED_PARAMETER,
|
|
19257
|
+
regex: vE(s.numbered, "[0-9]+"),
|
|
19053
19258
|
key: (O) => O.slice(1)
|
|
19054
19259
|
},
|
|
19055
19260
|
{
|
|
19056
|
-
type:
|
|
19261
|
+
type: D.POSITIONAL_PARAMETER,
|
|
19057
19262
|
regex: s.positional ? /[?]/y : void 0
|
|
19058
19263
|
},
|
|
19059
19264
|
...s.custom.map((O) => {
|
|
19060
19265
|
var N;
|
|
19061
19266
|
return {
|
|
19062
|
-
type:
|
|
19267
|
+
type: D.CUSTOM_PARAMETER,
|
|
19063
19268
|
regex: v(O.regex),
|
|
19064
19269
|
key: (N = O.key) !== null && N !== void 0 ? N : ((r) => r)
|
|
19065
19270
|
};
|
|
@@ -19071,13 +19276,13 @@ class zI {
|
|
|
19071
19276
|
return E.filter((e) => !!e.regex);
|
|
19072
19277
|
}
|
|
19073
19278
|
}
|
|
19074
|
-
const
|
|
19075
|
-
let E =
|
|
19076
|
-
return E || (E =
|
|
19077
|
-
},
|
|
19078
|
-
tokenizer: new
|
|
19079
|
-
formatOptions:
|
|
19080
|
-
}),
|
|
19279
|
+
const B = (T) => IE(T.toUpperCase()), KT = /* @__PURE__ */ new Map(), EI = (T) => {
|
|
19280
|
+
let E = KT.get(T);
|
|
19281
|
+
return E || (E = TI(T), KT.set(T, E)), E;
|
|
19282
|
+
}, TI = (T) => ({
|
|
19283
|
+
tokenizer: new zN(T.tokenizerOptions, T.name),
|
|
19284
|
+
formatOptions: eI(T.formatOptions)
|
|
19285
|
+
}), eI = (T) => {
|
|
19081
19286
|
var E;
|
|
19082
19287
|
return {
|
|
19083
19288
|
alwaysDenseOperators: T.alwaysDenseOperators || [],
|
|
@@ -19085,13 +19290,13 @@ const p = (T) => NE(T.toUpperCase()), gT = /* @__PURE__ */ new Map(), EN = (T) =
|
|
|
19085
19290
|
tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((e) => [e, !0]))
|
|
19086
19291
|
};
|
|
19087
19292
|
};
|
|
19088
|
-
function
|
|
19293
|
+
function RI(T) {
|
|
19089
19294
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
|
|
19090
19295
|
}
|
|
19091
19296
|
function j(T) {
|
|
19092
19297
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
|
|
19093
19298
|
}
|
|
19094
|
-
class
|
|
19299
|
+
class AI {
|
|
19095
19300
|
constructor(E) {
|
|
19096
19301
|
this.params = E, this.index = 0;
|
|
19097
19302
|
}
|
|
@@ -19114,15 +19319,15 @@ class AN {
|
|
|
19114
19319
|
this.index = E;
|
|
19115
19320
|
}
|
|
19116
19321
|
}
|
|
19117
|
-
function
|
|
19322
|
+
function SI(T) {
|
|
19118
19323
|
return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
|
|
19119
19324
|
}
|
|
19120
|
-
var OE = { exports: {} },
|
|
19121
|
-
function
|
|
19122
|
-
return
|
|
19325
|
+
var OE = { exports: {} }, NI = OE.exports, $T;
|
|
19326
|
+
function II() {
|
|
19327
|
+
return $T || ($T = 1, (function(T) {
|
|
19123
19328
|
(function(E, e) {
|
|
19124
19329
|
T.exports ? T.exports = e() : E.nearley = e();
|
|
19125
|
-
})(
|
|
19330
|
+
})(NI, function() {
|
|
19126
19331
|
function E(O, N, r) {
|
|
19127
19332
|
return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = r, this;
|
|
19128
19333
|
}
|
|
@@ -19151,12 +19356,12 @@ function NN() {
|
|
|
19151
19356
|
this.grammar = O, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
19152
19357
|
}
|
|
19153
19358
|
R.prototype.process = function(O) {
|
|
19154
|
-
for (var N = this.states, r = this.wants, n = this.completed,
|
|
19155
|
-
var i = N[
|
|
19359
|
+
for (var N = this.states, r = this.wants, n = this.completed, C = 0; C < N.length; C++) {
|
|
19360
|
+
var i = N[C];
|
|
19156
19361
|
if (i.isComplete) {
|
|
19157
19362
|
if (i.finish(), i.data !== I.fail) {
|
|
19158
|
-
for (var
|
|
19159
|
-
var P =
|
|
19363
|
+
for (var a = i.wantedBy, l = a.length; l--; ) {
|
|
19364
|
+
var P = a[l];
|
|
19160
19365
|
this.complete(P, i);
|
|
19161
19366
|
}
|
|
19162
19367
|
if (i.reference === this.index) {
|
|
@@ -19182,7 +19387,7 @@ function NN() {
|
|
|
19182
19387
|
}
|
|
19183
19388
|
}, R.prototype.predict = function(O) {
|
|
19184
19389
|
for (var N = this.grammar.byName[O] || [], r = 0; r < N.length; r++) {
|
|
19185
|
-
var n = N[r],
|
|
19390
|
+
var n = N[r], C = this.wants[O], i = new e(n, 0, this.index, C);
|
|
19186
19391
|
this.states.push(i);
|
|
19187
19392
|
}
|
|
19188
19393
|
}, R.prototype.complete = function(O, N) {
|
|
@@ -19201,8 +19406,8 @@ function NN() {
|
|
|
19201
19406
|
n.ParserStart && (N = n.ParserStart, n = n.ParserRules);
|
|
19202
19407
|
var n = n.map(function(i) {
|
|
19203
19408
|
return new E(i.name, i.symbols, i.postprocess);
|
|
19204
|
-
}),
|
|
19205
|
-
return
|
|
19409
|
+
}), C = new A(n, N);
|
|
19410
|
+
return C.lexer = r, C;
|
|
19206
19411
|
};
|
|
19207
19412
|
function S() {
|
|
19208
19413
|
this.reset("");
|
|
@@ -19227,17 +19432,17 @@ function NN() {
|
|
|
19227
19432
|
`).slice(
|
|
19228
19433
|
Math.max(0, this.line - 5),
|
|
19229
19434
|
this.line
|
|
19230
|
-
),
|
|
19435
|
+
), C = r.indexOf(`
|
|
19231
19436
|
`, this.index);
|
|
19232
|
-
|
|
19233
|
-
var i = this.index - this.lastLineBreak,
|
|
19437
|
+
C === -1 && (C = r.length);
|
|
19438
|
+
var i = this.index - this.lastLineBreak, a = String(this.line).length;
|
|
19234
19439
|
return N += " at line " + this.line + " col " + i + `:
|
|
19235
19440
|
|
|
19236
19441
|
`, N += n.map(function(P, U) {
|
|
19237
|
-
return l(this.line - n.length + U + 1,
|
|
19442
|
+
return l(this.line - n.length + U + 1, a) + " " + P;
|
|
19238
19443
|
}, this).join(`
|
|
19239
19444
|
`), N += `
|
|
19240
|
-
` + l("",
|
|
19445
|
+
` + l("", a + i) + `^
|
|
19241
19446
|
`, N;
|
|
19242
19447
|
} else
|
|
19243
19448
|
return N + " at index " + (this.index - 1);
|
|
@@ -19255,8 +19460,8 @@ function NN() {
|
|
|
19255
19460
|
keepHistory: !1,
|
|
19256
19461
|
lexer: n.lexer || new S()
|
|
19257
19462
|
};
|
|
19258
|
-
for (var
|
|
19259
|
-
this.options[
|
|
19463
|
+
for (var C in r || {})
|
|
19464
|
+
this.options[C] = r[C];
|
|
19260
19465
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
19261
19466
|
var i = new R(n, 0);
|
|
19262
19467
|
this.table = [i], i.wants[n.start] = [], i.predict(n.start), i.process(), this.current = 0;
|
|
@@ -19268,30 +19473,30 @@ function NN() {
|
|
|
19268
19473
|
try {
|
|
19269
19474
|
if (r = N.next(), !r)
|
|
19270
19475
|
break;
|
|
19271
|
-
} catch (
|
|
19272
|
-
var
|
|
19273
|
-
this.table.push(
|
|
19274
|
-
var n = new Error(this.reportLexerError(
|
|
19275
|
-
throw n.offset = this.current, n.token =
|
|
19476
|
+
} catch (y) {
|
|
19477
|
+
var a = new R(this.grammar, this.current + 1);
|
|
19478
|
+
this.table.push(a);
|
|
19479
|
+
var n = new Error(this.reportLexerError(y));
|
|
19480
|
+
throw n.offset = this.current, n.token = y.token, n;
|
|
19276
19481
|
}
|
|
19277
|
-
var
|
|
19482
|
+
var C = this.table[this.current];
|
|
19278
19483
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
19279
|
-
var i = this.current + 1,
|
|
19280
|
-
this.table.push(
|
|
19281
|
-
for (var l = r.text !== void 0 ? r.text : r.value, P = N.constructor === S ? r.value : r, U =
|
|
19484
|
+
var i = this.current + 1, a = new R(this.grammar, i);
|
|
19485
|
+
this.table.push(a);
|
|
19486
|
+
for (var l = r.text !== void 0 ? r.text : r.value, P = N.constructor === S ? r.value : r, U = C.scannable, M = U.length; M--; ) {
|
|
19282
19487
|
var G = U[M], m = G.rule.symbols[G.dot];
|
|
19283
19488
|
if (m.test ? m.test(P) : m.type ? m.type === r.type : m.literal === l) {
|
|
19284
|
-
var
|
|
19285
|
-
|
|
19489
|
+
var p = G.nextState({ data: P, token: r, isToken: !0, reference: i - 1 });
|
|
19490
|
+
a.states.push(p);
|
|
19286
19491
|
}
|
|
19287
19492
|
}
|
|
19288
|
-
if (
|
|
19493
|
+
if (a.process(), a.states.length === 0) {
|
|
19289
19494
|
var n = new Error(this.reportError(r));
|
|
19290
19495
|
throw n.offset = this.current, n.token = r, n;
|
|
19291
19496
|
}
|
|
19292
|
-
this.options.keepHistory && (
|
|
19497
|
+
this.options.keepHistory && (C.lexerState = N.save()), this.current++;
|
|
19293
19498
|
}
|
|
19294
|
-
return
|
|
19499
|
+
return C && (this.lexerState = N.save()), this.results = this.finish(), this;
|
|
19295
19500
|
}, I.prototype.reportLexerError = function(O) {
|
|
19296
19501
|
var N, r, n = O.token;
|
|
19297
19502
|
return n ? (N = "input " + JSON.stringify(n.text[0]) + " (lexer error)", r = this.lexer.formatError(n, "Syntax error")) : (N = "input (lexer error)", r = O.message), this.reportErrorCommon(r, N);
|
|
@@ -19301,20 +19506,20 @@ function NN() {
|
|
|
19301
19506
|
}, I.prototype.reportErrorCommon = function(O, N) {
|
|
19302
19507
|
var r = [];
|
|
19303
19508
|
r.push(O);
|
|
19304
|
-
var n = this.table.length - 2,
|
|
19509
|
+
var n = this.table.length - 2, C = this.table[n], i = C.states.filter(function(l) {
|
|
19305
19510
|
var P = l.rule.symbols[l.dot];
|
|
19306
19511
|
return P && typeof P != "string";
|
|
19307
19512
|
});
|
|
19308
19513
|
if (i.length === 0)
|
|
19309
19514
|
r.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
|
|
19310
|
-
`), this.displayStateStack(
|
|
19515
|
+
`), this.displayStateStack(C.states, r);
|
|
19311
19516
|
else {
|
|
19312
19517
|
r.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
19313
19518
|
`);
|
|
19314
|
-
var
|
|
19519
|
+
var a = i.map(function(l) {
|
|
19315
19520
|
return this.buildFirstStateStack(l, []) || [l];
|
|
19316
19521
|
}, this);
|
|
19317
|
-
|
|
19522
|
+
a.forEach(function(l) {
|
|
19318
19523
|
var P = l[0], U = P.rule.symbols[P.dot], M = this.getSymbolDisplay(U);
|
|
19319
19524
|
r.push("A " + M + " based on:"), this.displayStateStack(l, r);
|
|
19320
19525
|
}, this);
|
|
@@ -19322,9 +19527,9 @@ function NN() {
|
|
|
19322
19527
|
return r.push(""), r.join(`
|
|
19323
19528
|
`);
|
|
19324
19529
|
}, I.prototype.displayStateStack = function(O, N) {
|
|
19325
|
-
for (var r, n = 0,
|
|
19326
|
-
var i = O[
|
|
19327
|
-
|
|
19530
|
+
for (var r, n = 0, C = 0; C < O.length; C++) {
|
|
19531
|
+
var i = O[C], a = i.rule.toString(i.dot);
|
|
19532
|
+
a === r ? n++ : (n > 0 && N.push(" ^ " + n + " more lines identical to this"), n = 0, N.push(" " + a)), r = a;
|
|
19328
19533
|
}
|
|
19329
19534
|
}, I.prototype.getSymbolDisplay = function(O) {
|
|
19330
19535
|
return t(O);
|
|
@@ -19333,8 +19538,8 @@ function NN() {
|
|
|
19333
19538
|
return null;
|
|
19334
19539
|
if (O.wantedBy.length === 0)
|
|
19335
19540
|
return [O];
|
|
19336
|
-
var r = O.wantedBy[0], n = [O].concat(N),
|
|
19337
|
-
return
|
|
19541
|
+
var r = O.wantedBy[0], n = [O].concat(N), C = this.buildFirstStateStack(r, n);
|
|
19542
|
+
return C === null ? null : [O].concat(C);
|
|
19338
19543
|
}, I.prototype.save = function() {
|
|
19339
19544
|
var O = this.table[this.current];
|
|
19340
19545
|
return O.lexerState = this.lexerState, O;
|
|
@@ -19393,56 +19598,56 @@ function NN() {
|
|
|
19393
19598
|
});
|
|
19394
19599
|
})(OE)), OE.exports;
|
|
19395
19600
|
}
|
|
19396
|
-
var
|
|
19397
|
-
const
|
|
19398
|
-
function
|
|
19399
|
-
return T.map(
|
|
19601
|
+
var OI = II();
|
|
19602
|
+
const tI = /* @__PURE__ */ SI(OI);
|
|
19603
|
+
function sI(T) {
|
|
19604
|
+
return T.map(rI).map(nI).map(CI).map(LI).map(_I);
|
|
19400
19605
|
}
|
|
19401
|
-
const
|
|
19402
|
-
if (
|
|
19403
|
-
const R =
|
|
19404
|
-
if (R && R.type ===
|
|
19405
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19606
|
+
const rI = (T, E, e) => {
|
|
19607
|
+
if (Re(T.type)) {
|
|
19608
|
+
const R = iI(e, E);
|
|
19609
|
+
if (R && R.type === D.PROPERTY_ACCESS_OPERATOR)
|
|
19610
|
+
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
19406
19611
|
const A = EE(e, E);
|
|
19407
|
-
if (A && A.type ===
|
|
19408
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19612
|
+
if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
|
|
19613
|
+
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
19409
19614
|
}
|
|
19410
19615
|
return T;
|
|
19411
|
-
},
|
|
19412
|
-
if (T.type ===
|
|
19616
|
+
}, nI = (T, E, e) => {
|
|
19617
|
+
if (T.type === D.RESERVED_FUNCTION_NAME) {
|
|
19413
19618
|
const R = EE(e, E);
|
|
19414
|
-
if (!R || !
|
|
19415
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19619
|
+
if (!R || !te(R))
|
|
19620
|
+
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
19416
19621
|
}
|
|
19417
19622
|
return T;
|
|
19418
|
-
},
|
|
19419
|
-
if (T.type ===
|
|
19623
|
+
}, CI = (T, E, e) => {
|
|
19624
|
+
if (T.type === D.RESERVED_DATA_TYPE) {
|
|
19420
19625
|
const R = EE(e, E);
|
|
19421
|
-
if (R &&
|
|
19422
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19626
|
+
if (R && te(R))
|
|
19627
|
+
return Object.assign(Object.assign({}, T), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
19423
19628
|
}
|
|
19424
19629
|
return T;
|
|
19425
|
-
},
|
|
19426
|
-
if (T.type ===
|
|
19630
|
+
}, LI = (T, E, e) => {
|
|
19631
|
+
if (T.type === D.IDENTIFIER) {
|
|
19427
19632
|
const R = EE(e, E);
|
|
19428
|
-
if (R &&
|
|
19429
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19633
|
+
if (R && se(R))
|
|
19634
|
+
return Object.assign(Object.assign({}, T), { type: D.ARRAY_IDENTIFIER });
|
|
19430
19635
|
}
|
|
19431
19636
|
return T;
|
|
19432
|
-
},
|
|
19433
|
-
if (T.type ===
|
|
19637
|
+
}, _I = (T, E, e) => {
|
|
19638
|
+
if (T.type === D.RESERVED_DATA_TYPE) {
|
|
19434
19639
|
const R = EE(e, E);
|
|
19435
|
-
if (R &&
|
|
19436
|
-
return Object.assign(Object.assign({}, T), { type:
|
|
19640
|
+
if (R && se(R))
|
|
19641
|
+
return Object.assign(Object.assign({}, T), { type: D.ARRAY_KEYWORD });
|
|
19437
19642
|
}
|
|
19438
19643
|
return T;
|
|
19439
|
-
},
|
|
19644
|
+
}, iI = (T, E) => EE(T, E, -1), EE = (T, E, e = 1) => {
|
|
19440
19645
|
let R = 1;
|
|
19441
|
-
for (; T[E + R * e] &&
|
|
19646
|
+
for (; T[E + R * e] && aI(T[E + R * e]); )
|
|
19442
19647
|
R++;
|
|
19443
19648
|
return T[E + R * e];
|
|
19444
|
-
},
|
|
19445
|
-
class
|
|
19649
|
+
}, te = (T) => T.type === D.OPEN_PAREN && T.text === "(", se = (T) => T.type === D.OPEN_PAREN && T.text === "[", aI = (T) => T.type === D.BLOCK_COMMENT || T.type === D.LINE_COMMENT;
|
|
19650
|
+
class re {
|
|
19446
19651
|
constructor(E) {
|
|
19447
19652
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
19448
19653
|
}
|
|
@@ -19455,30 +19660,30 @@ class se {
|
|
|
19455
19660
|
save() {
|
|
19456
19661
|
}
|
|
19457
19662
|
formatError(E) {
|
|
19458
|
-
const { line: e, col: R } =
|
|
19663
|
+
const { line: e, col: R } = Oe(this.input, E.start);
|
|
19459
19664
|
return `Parse error at token: ${E.text} at line ${e} column ${R}`;
|
|
19460
19665
|
}
|
|
19461
19666
|
has(E) {
|
|
19462
|
-
return E in
|
|
19667
|
+
return E in D;
|
|
19463
19668
|
}
|
|
19464
19669
|
}
|
|
19465
19670
|
var c;
|
|
19466
19671
|
(function(T) {
|
|
19467
19672
|
T.statement = "statement", T.clause = "clause", T.set_operation = "set_operation", T.function_call = "function_call", T.parameterized_data_type = "parameterized_data_type", T.array_subscript = "array_subscript", T.property_access = "property_access", T.parenthesis = "parenthesis", T.between_predicate = "between_predicate", T.case_expression = "case_expression", T.case_when = "case_when", T.case_else = "case_else", T.limit_clause = "limit_clause", T.all_columns_asterisk = "all_columns_asterisk", T.literal = "literal", T.identifier = "identifier", T.keyword = "keyword", T.data_type = "data_type", T.parameter = "parameter", T.operator = "operator", T.comma = "comma", T.line_comment = "line_comment", T.block_comment = "block_comment", T.disable_comment = "disable_comment";
|
|
19468
19673
|
})(c = c || (c = {}));
|
|
19469
|
-
function
|
|
19674
|
+
function QE(T) {
|
|
19470
19675
|
return T[0];
|
|
19471
19676
|
}
|
|
19472
|
-
const u = new
|
|
19677
|
+
const u = new re((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
19473
19678
|
type: c.keyword,
|
|
19474
19679
|
tokenType: T.type,
|
|
19475
19680
|
text: T.text,
|
|
19476
19681
|
raw: T.raw
|
|
19477
|
-
}),
|
|
19682
|
+
}), wT = (T) => ({
|
|
19478
19683
|
type: c.data_type,
|
|
19479
19684
|
text: T.text,
|
|
19480
19685
|
raw: T.raw
|
|
19481
|
-
}), Y = (T, { leading: E, trailing: e }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), e?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: e })), T),
|
|
19686
|
+
}), Y = (T, { leading: E, trailing: e }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), e?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: e })), T), oI = (T, { leading: E, trailing: e }) => {
|
|
19482
19687
|
if (E?.length) {
|
|
19483
19688
|
const [R, ...A] = T;
|
|
19484
19689
|
T = [Y(R, { leading: E }), ...A];
|
|
@@ -19488,7 +19693,7 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19488
19693
|
T = [...R, Y(A, { trailing: e })];
|
|
19489
19694
|
}
|
|
19490
19695
|
return T;
|
|
19491
|
-
},
|
|
19696
|
+
}, DI = {
|
|
19492
19697
|
Lexer: u,
|
|
19493
19698
|
ParserRules: [
|
|
19494
19699
|
{ name: "main$ebnf$1", symbols: [] },
|
|
@@ -19509,7 +19714,7 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19509
19714
|
postprocess: ([T, [E]]) => ({
|
|
19510
19715
|
type: c.statement,
|
|
19511
19716
|
children: T,
|
|
19512
|
-
hasSemicolon: E.type ===
|
|
19717
|
+
hasSemicolon: E.type === D.DELIMITER
|
|
19513
19718
|
})
|
|
19514
19719
|
},
|
|
19515
19720
|
{ name: "expressions_or_clauses$ebnf$1", symbols: [] },
|
|
@@ -19529,7 +19734,7 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19529
19734
|
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
|
|
19530
19735
|
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
19531
19736
|
{ name: "limit_clause$ebnf$1$subexpression$1", symbols: [u.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
|
|
19532
|
-
{ name: "limit_clause$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1"], postprocess:
|
|
19737
|
+
{ name: "limit_clause$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1"], postprocess: QE },
|
|
19533
19738
|
{ name: "limit_clause$ebnf$1", symbols: [], postprocess: () => null },
|
|
19534
19739
|
{
|
|
19535
19740
|
name: "limit_clause",
|
|
@@ -19604,7 +19809,7 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19604
19809
|
},
|
|
19605
19810
|
{ name: "expression_chain_$ebnf$1", symbols: ["expression_with_comments_"] },
|
|
19606
19811
|
{ name: "expression_chain_$ebnf$1", symbols: ["expression_chain_$ebnf$1", "expression_with_comments_"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
19607
|
-
{ name: "expression_chain_", symbols: ["expression_chain_$ebnf$1"], postprocess:
|
|
19812
|
+
{ name: "expression_chain_", symbols: ["expression_chain_$ebnf$1"], postprocess: QE },
|
|
19608
19813
|
{ name: "expression_chain$ebnf$1", symbols: [] },
|
|
19609
19814
|
{ name: "expression_chain$ebnf$1", symbols: ["expression_chain$ebnf$1", "_expression_with_comments"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
19610
19815
|
{
|
|
@@ -19753,12 +19958,12 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19753
19958
|
postprocess: ([T, E, e, R, A, S, I]) => ({
|
|
19754
19959
|
type: c.between_predicate,
|
|
19755
19960
|
betweenKw: F(T),
|
|
19756
|
-
expr1:
|
|
19961
|
+
expr1: oI(e, { leading: E, trailing: R }),
|
|
19757
19962
|
andKw: F(A),
|
|
19758
19963
|
expr2: [Y(I, { leading: S })]
|
|
19759
19964
|
})
|
|
19760
19965
|
},
|
|
19761
|
-
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess:
|
|
19966
|
+
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: QE },
|
|
19762
19967
|
{ name: "case_expression$ebnf$1", symbols: [], postprocess: () => null },
|
|
19763
19968
|
{ name: "case_expression$ebnf$2", symbols: [] },
|
|
19764
19969
|
{ name: "case_expression$ebnf$2", symbols: ["case_expression$ebnf$2", "case_clause"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
@@ -19825,14 +20030,14 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19825
20030
|
{
|
|
19826
20031
|
name: "data_type",
|
|
19827
20032
|
symbols: ["data_type$subexpression$1"],
|
|
19828
|
-
postprocess: ([[T]]) =>
|
|
20033
|
+
postprocess: ([[T]]) => wT(T)
|
|
19829
20034
|
},
|
|
19830
20035
|
{
|
|
19831
20036
|
name: "data_type",
|
|
19832
20037
|
symbols: [u.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
19833
20038
|
postprocess: ([T, E, e]) => ({
|
|
19834
20039
|
type: c.parameterized_data_type,
|
|
19835
|
-
dataType: Y(
|
|
20040
|
+
dataType: Y(wT(T), { trailing: E }),
|
|
19836
20041
|
parenthesis: e
|
|
19837
20042
|
})
|
|
19838
20043
|
},
|
|
@@ -19885,13 +20090,13 @@ const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19885
20090
|
}
|
|
19886
20091
|
],
|
|
19887
20092
|
ParserStart: "main"
|
|
19888
|
-
}, { Parser:
|
|
19889
|
-
function
|
|
20093
|
+
}, { Parser: PI, Grammar: MI } = tI;
|
|
20094
|
+
function UI(T) {
|
|
19890
20095
|
let E = {};
|
|
19891
|
-
const e = new
|
|
19892
|
-
...
|
|
19893
|
-
|
|
19894
|
-
]), R = new
|
|
20096
|
+
const e = new re((A) => [
|
|
20097
|
+
...sI(T.tokenize(A, E)),
|
|
20098
|
+
ee(A.length)
|
|
20099
|
+
]), R = new PI(MI.fromCompiled(DI), { lexer: e });
|
|
19895
20100
|
return {
|
|
19896
20101
|
parse: (A, S) => {
|
|
19897
20102
|
E = S;
|
|
@@ -19903,11 +20108,11 @@ ${JSON.stringify(I, void 0, 2)}`);
|
|
|
19903
20108
|
}
|
|
19904
20109
|
};
|
|
19905
20110
|
}
|
|
19906
|
-
var
|
|
20111
|
+
var o;
|
|
19907
20112
|
(function(T) {
|
|
19908
20113
|
T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
19909
|
-
})(
|
|
19910
|
-
class
|
|
20114
|
+
})(o = o || (o = {}));
|
|
20115
|
+
class ne {
|
|
19911
20116
|
constructor(E) {
|
|
19912
20117
|
this.indentation = E, this.items = [];
|
|
19913
20118
|
}
|
|
@@ -19917,46 +20122,46 @@ class re {
|
|
|
19917
20122
|
add(...E) {
|
|
19918
20123
|
for (const e of E)
|
|
19919
20124
|
switch (e) {
|
|
19920
|
-
case
|
|
19921
|
-
this.items.push(
|
|
20125
|
+
case o.SPACE:
|
|
20126
|
+
this.items.push(o.SPACE);
|
|
19922
20127
|
break;
|
|
19923
|
-
case
|
|
20128
|
+
case o.NO_SPACE:
|
|
19924
20129
|
this.trimHorizontalWhitespace();
|
|
19925
20130
|
break;
|
|
19926
|
-
case
|
|
20131
|
+
case o.NO_NEWLINE:
|
|
19927
20132
|
this.trimWhitespace();
|
|
19928
20133
|
break;
|
|
19929
|
-
case
|
|
19930
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
20134
|
+
case o.NEWLINE:
|
|
20135
|
+
this.trimHorizontalWhitespace(), this.addNewline(o.NEWLINE);
|
|
19931
20136
|
break;
|
|
19932
|
-
case
|
|
19933
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
20137
|
+
case o.MANDATORY_NEWLINE:
|
|
20138
|
+
this.trimHorizontalWhitespace(), this.addNewline(o.MANDATORY_NEWLINE);
|
|
19934
20139
|
break;
|
|
19935
|
-
case
|
|
20140
|
+
case o.INDENT:
|
|
19936
20141
|
this.addIndentation();
|
|
19937
20142
|
break;
|
|
19938
|
-
case
|
|
19939
|
-
this.items.push(
|
|
20143
|
+
case o.SINGLE_INDENT:
|
|
20144
|
+
this.items.push(o.SINGLE_INDENT);
|
|
19940
20145
|
break;
|
|
19941
20146
|
default:
|
|
19942
20147
|
this.items.push(e);
|
|
19943
20148
|
}
|
|
19944
20149
|
}
|
|
19945
20150
|
trimHorizontalWhitespace() {
|
|
19946
|
-
for (;
|
|
20151
|
+
for (; cI(eE(this.items)); )
|
|
19947
20152
|
this.items.pop();
|
|
19948
20153
|
}
|
|
19949
20154
|
trimWhitespace() {
|
|
19950
|
-
for (;
|
|
20155
|
+
for (; lI(eE(this.items)); )
|
|
19951
20156
|
this.items.pop();
|
|
19952
20157
|
}
|
|
19953
20158
|
addNewline(E) {
|
|
19954
20159
|
if (this.items.length > 0)
|
|
19955
20160
|
switch (eE(this.items)) {
|
|
19956
|
-
case
|
|
20161
|
+
case o.NEWLINE:
|
|
19957
20162
|
this.items.pop(), this.items.push(E);
|
|
19958
20163
|
break;
|
|
19959
|
-
case
|
|
20164
|
+
case o.MANDATORY_NEWLINE:
|
|
19960
20165
|
break;
|
|
19961
20166
|
default:
|
|
19962
20167
|
this.items.push(E);
|
|
@@ -19965,7 +20170,7 @@ class re {
|
|
|
19965
20170
|
}
|
|
19966
20171
|
addIndentation() {
|
|
19967
20172
|
for (let E = 0; E < this.indentation.getLevel(); E++)
|
|
19968
|
-
this.items.push(
|
|
20173
|
+
this.items.push(o.SINGLE_INDENT);
|
|
19969
20174
|
}
|
|
19970
20175
|
/**
|
|
19971
20176
|
* Returns the final SQL string.
|
|
@@ -19981,30 +20186,30 @@ class re {
|
|
|
19981
20186
|
}
|
|
19982
20187
|
itemToString(E) {
|
|
19983
20188
|
switch (E) {
|
|
19984
|
-
case
|
|
20189
|
+
case o.SPACE:
|
|
19985
20190
|
return " ";
|
|
19986
|
-
case
|
|
19987
|
-
case
|
|
20191
|
+
case o.NEWLINE:
|
|
20192
|
+
case o.MANDATORY_NEWLINE:
|
|
19988
20193
|
return `
|
|
19989
20194
|
`;
|
|
19990
|
-
case
|
|
20195
|
+
case o.SINGLE_INDENT:
|
|
19991
20196
|
return this.indentation.getSingleIndent();
|
|
19992
20197
|
default:
|
|
19993
20198
|
return E;
|
|
19994
20199
|
}
|
|
19995
20200
|
}
|
|
19996
20201
|
}
|
|
19997
|
-
const
|
|
19998
|
-
function
|
|
20202
|
+
const cI = (T) => T === o.SPACE || T === o.SINGLE_INDENT, lI = (T) => T === o.SPACE || T === o.SINGLE_INDENT || T === o.NEWLINE;
|
|
20203
|
+
function JT(T, E) {
|
|
19999
20204
|
if (E === "standard")
|
|
20000
20205
|
return T;
|
|
20001
20206
|
let e = [];
|
|
20002
20207
|
return T.length >= 10 && T.includes(" ") && ([T, ...e] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...e].join(" ");
|
|
20003
20208
|
}
|
|
20004
|
-
function
|
|
20005
|
-
return AR(T) || T ===
|
|
20209
|
+
function xT(T) {
|
|
20210
|
+
return AR(T) || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.LIMIT;
|
|
20006
20211
|
}
|
|
20007
|
-
const
|
|
20212
|
+
const ZE = "top-level", uI = "block-level";
|
|
20008
20213
|
class Ce {
|
|
20009
20214
|
/**
|
|
20010
20215
|
* @param {string} indent A string to indent with
|
|
@@ -20028,20 +20233,20 @@ class Ce {
|
|
|
20028
20233
|
* Increases indentation by one top-level indent.
|
|
20029
20234
|
*/
|
|
20030
20235
|
increaseTopLevel() {
|
|
20031
|
-
this.indentTypes.push(
|
|
20236
|
+
this.indentTypes.push(ZE);
|
|
20032
20237
|
}
|
|
20033
20238
|
/**
|
|
20034
20239
|
* Increases indentation by one block-level indent.
|
|
20035
20240
|
*/
|
|
20036
20241
|
increaseBlockLevel() {
|
|
20037
|
-
this.indentTypes.push(
|
|
20242
|
+
this.indentTypes.push(uI);
|
|
20038
20243
|
}
|
|
20039
20244
|
/**
|
|
20040
20245
|
* Decreases indentation by one top-level indent.
|
|
20041
20246
|
* Does nothing when the previous indent is not top-level.
|
|
20042
20247
|
*/
|
|
20043
20248
|
decreaseTopLevel() {
|
|
20044
|
-
this.indentTypes.length > 0 && eE(this.indentTypes) ===
|
|
20249
|
+
this.indentTypes.length > 0 && eE(this.indentTypes) === ZE && this.indentTypes.pop();
|
|
20045
20250
|
}
|
|
20046
20251
|
/**
|
|
20047
20252
|
* Decreases indentation by one block-level indent.
|
|
@@ -20049,32 +20254,32 @@ class Ce {
|
|
|
20049
20254
|
* throws away these as well.
|
|
20050
20255
|
*/
|
|
20051
20256
|
decreaseBlockLevel() {
|
|
20052
|
-
for (; this.indentTypes.length > 0 && this.indentTypes.pop() ===
|
|
20257
|
+
for (; this.indentTypes.length > 0 && this.indentTypes.pop() === ZE; )
|
|
20053
20258
|
;
|
|
20054
20259
|
}
|
|
20055
20260
|
}
|
|
20056
|
-
class
|
|
20261
|
+
class GI extends ne {
|
|
20057
20262
|
constructor(E) {
|
|
20058
20263
|
super(new Ce("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
20059
20264
|
}
|
|
20060
20265
|
add(...E) {
|
|
20061
20266
|
if (E.forEach((e) => this.addToLength(e)), this.length > this.expressionWidth)
|
|
20062
|
-
throw new
|
|
20267
|
+
throw new kE();
|
|
20063
20268
|
super.add(...E);
|
|
20064
20269
|
}
|
|
20065
20270
|
addToLength(E) {
|
|
20066
20271
|
if (typeof E == "string")
|
|
20067
20272
|
this.length += E.length, this.trailingSpace = !1;
|
|
20068
20273
|
else {
|
|
20069
|
-
if (E ===
|
|
20070
|
-
throw new
|
|
20071
|
-
E ===
|
|
20274
|
+
if (E === o.MANDATORY_NEWLINE || E === o.NEWLINE)
|
|
20275
|
+
throw new kE();
|
|
20276
|
+
E === o.INDENT || E === o.SINGLE_INDENT || E === o.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === o.NO_NEWLINE || E === o.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
|
|
20072
20277
|
}
|
|
20073
20278
|
}
|
|
20074
20279
|
}
|
|
20075
|
-
class
|
|
20280
|
+
class kE extends Error {
|
|
20076
20281
|
}
|
|
20077
|
-
class
|
|
20282
|
+
class CE {
|
|
20078
20283
|
constructor({ cfg: E, dialectCfg: e, params: R, layout: A, inline: S = !1 }) {
|
|
20079
20284
|
this.inline = !1, this.nodes = [], this.index = -1, this.cfg = E, this.dialectCfg = e, this.inline = S, this.params = R, this.layout = A;
|
|
20080
20285
|
}
|
|
@@ -20164,23 +20369,23 @@ class nE {
|
|
|
20164
20369
|
}), this.formatNode(E.parenthesis);
|
|
20165
20370
|
}
|
|
20166
20371
|
formatPropertyAccess(E) {
|
|
20167
|
-
this.formatNode(E.object), this.layout.add(
|
|
20372
|
+
this.formatNode(E.object), this.layout.add(o.NO_SPACE, E.operator), this.formatNode(E.property);
|
|
20168
20373
|
}
|
|
20169
20374
|
formatParenthesis(E) {
|
|
20170
20375
|
const e = this.formatInlineExpression(E.children);
|
|
20171
|
-
e ? (this.layout.add(E.openParen), this.layout.add(...e.getLayoutItems()), this.layout.add(
|
|
20376
|
+
e ? (this.layout.add(E.openParen), this.layout.add(...e.getLayoutItems()), this.layout.add(o.NO_SPACE, E.closeParen, o.SPACE)) : (this.layout.add(E.openParen, o.NEWLINE), j(this.cfg) ? (this.layout.add(o.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(o.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(o.NEWLINE, o.INDENT, E.closeParen, o.SPACE));
|
|
20172
20377
|
}
|
|
20173
20378
|
formatBetweenPredicate(E) {
|
|
20174
|
-
this.layout.add(this.showKw(E.betweenKw),
|
|
20379
|
+
this.layout.add(this.showKw(E.betweenKw), o.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(o.NO_SPACE, o.SPACE, this.showNonTabularKw(E.andKw), o.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(o.SPACE);
|
|
20175
20380
|
}
|
|
20176
20381
|
formatCaseExpression(E) {
|
|
20177
|
-
this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(
|
|
20382
|
+
this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(o.NEWLINE, o.INDENT), this.formatNode(E.endKw);
|
|
20178
20383
|
}
|
|
20179
20384
|
formatCaseWhen(E) {
|
|
20180
|
-
this.layout.add(
|
|
20385
|
+
this.layout.add(o.NEWLINE, o.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
|
|
20181
20386
|
}
|
|
20182
20387
|
formatCaseElse(E) {
|
|
20183
|
-
this.layout.add(
|
|
20388
|
+
this.layout.add(o.NEWLINE, o.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
|
|
20184
20389
|
}
|
|
20185
20390
|
formatClause(E) {
|
|
20186
20391
|
this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : j(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
|
|
@@ -20189,39 +20394,39 @@ class nE {
|
|
|
20189
20394
|
return j(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
|
|
20190
20395
|
}
|
|
20191
20396
|
formatClauseInIndentedStyle(E) {
|
|
20192
|
-
this.layout.add(
|
|
20397
|
+
this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E.nameKw), o.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(o.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
|
|
20193
20398
|
}
|
|
20194
20399
|
formatClauseInOnelineStyle(E) {
|
|
20195
|
-
this.layout.add(
|
|
20400
|
+
this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E.nameKw), o.SPACE), this.layout = this.formatSubExpression(E.children);
|
|
20196
20401
|
}
|
|
20197
20402
|
formatClauseInTabularStyle(E) {
|
|
20198
|
-
this.layout.add(
|
|
20403
|
+
this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E.nameKw), o.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
|
|
20199
20404
|
}
|
|
20200
20405
|
formatSetOperation(E) {
|
|
20201
|
-
this.layout.add(
|
|
20406
|
+
this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E.nameKw), o.NEWLINE), this.layout.add(o.INDENT), this.layout = this.formatSubExpression(E.children);
|
|
20202
20407
|
}
|
|
20203
20408
|
formatLimitClause(E) {
|
|
20204
20409
|
this.withComments(E.limitKw, () => {
|
|
20205
|
-
this.layout.add(
|
|
20206
|
-
}), this.layout.indentation.increaseTopLevel(), j(this.cfg) ? this.layout.add(
|
|
20410
|
+
this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E.limitKw));
|
|
20411
|
+
}), this.layout.indentation.increaseTopLevel(), j(this.cfg) ? this.layout.add(o.SPACE) : this.layout.add(o.NEWLINE, o.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(o.NO_SPACE, ",", o.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
|
|
20207
20412
|
}
|
|
20208
20413
|
formatAllColumnsAsterisk(E) {
|
|
20209
|
-
this.layout.add("*",
|
|
20414
|
+
this.layout.add("*", o.SPACE);
|
|
20210
20415
|
}
|
|
20211
20416
|
formatLiteral(E) {
|
|
20212
|
-
this.layout.add(E.text,
|
|
20417
|
+
this.layout.add(E.text, o.SPACE);
|
|
20213
20418
|
}
|
|
20214
20419
|
formatIdentifier(E) {
|
|
20215
|
-
this.layout.add(this.showIdentifier(E),
|
|
20420
|
+
this.layout.add(this.showIdentifier(E), o.SPACE);
|
|
20216
20421
|
}
|
|
20217
20422
|
formatParameter(E) {
|
|
20218
|
-
this.layout.add(this.params.get(E),
|
|
20423
|
+
this.layout.add(this.params.get(E), o.SPACE);
|
|
20219
20424
|
}
|
|
20220
20425
|
formatOperator({ text: E }) {
|
|
20221
|
-
this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(
|
|
20426
|
+
this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(o.NO_SPACE, E) : E === ":" ? this.layout.add(o.NO_SPACE, E, o.SPACE) : this.layout.add(E, o.SPACE);
|
|
20222
20427
|
}
|
|
20223
20428
|
formatComma(E) {
|
|
20224
|
-
this.inline ? this.layout.add(
|
|
20429
|
+
this.inline ? this.layout.add(o.NO_SPACE, ",", o.SPACE) : this.layout.add(o.NO_SPACE, ",", o.NEWLINE, o.INDENT);
|
|
20225
20430
|
}
|
|
20226
20431
|
withComments(E, e) {
|
|
20227
20432
|
this.formatComments(E.leadingComments), e(), this.formatComments(E.trailingComments);
|
|
@@ -20232,15 +20437,15 @@ class nE {
|
|
|
20232
20437
|
});
|
|
20233
20438
|
}
|
|
20234
20439
|
formatLineComment(E) {
|
|
20235
|
-
|
|
20440
|
+
xE(E.precedingWhitespace || "") ? this.layout.add(o.NEWLINE, o.INDENT, E.text, o.MANDATORY_NEWLINE, o.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(o.NO_NEWLINE, o.SPACE, E.text, o.MANDATORY_NEWLINE, o.INDENT) : this.layout.add(E.text, o.MANDATORY_NEWLINE, o.INDENT);
|
|
20236
20441
|
}
|
|
20237
20442
|
formatBlockComment(E) {
|
|
20238
20443
|
E.type === c.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((e) => {
|
|
20239
|
-
this.layout.add(
|
|
20240
|
-
}), this.layout.add(
|
|
20444
|
+
this.layout.add(o.NEWLINE, o.INDENT, e);
|
|
20445
|
+
}), this.layout.add(o.NEWLINE, o.INDENT)) : this.layout.add(E.text, o.SPACE);
|
|
20241
20446
|
}
|
|
20242
20447
|
isMultilineBlockComment(E) {
|
|
20243
|
-
return
|
|
20448
|
+
return xE(E.text) || xE(E.precedingWhitespace || "");
|
|
20244
20449
|
}
|
|
20245
20450
|
isDocComment(E) {
|
|
20246
20451
|
const e = E.split(/\n/);
|
|
@@ -20282,7 +20487,7 @@ class nE {
|
|
|
20282
20487
|
return this.isDocComment(E) ? E.split(/\n/).map((e) => /^\s*\*/.test(e) ? " " + e.replace(/^\s*/, "") : e) : E.split(/\n/).map((e) => e.replace(/^\s*/, ""));
|
|
20283
20488
|
}
|
|
20284
20489
|
formatSubExpression(E) {
|
|
20285
|
-
return new
|
|
20490
|
+
return new CE({
|
|
20286
20491
|
cfg: this.cfg,
|
|
20287
20492
|
dialectCfg: this.dialectCfg,
|
|
20288
20493
|
params: this.params,
|
|
@@ -20293,15 +20498,15 @@ class nE {
|
|
|
20293
20498
|
formatInlineExpression(E) {
|
|
20294
20499
|
const e = this.params.getPositionalParameterIndex();
|
|
20295
20500
|
try {
|
|
20296
|
-
return new
|
|
20501
|
+
return new CE({
|
|
20297
20502
|
cfg: this.cfg,
|
|
20298
20503
|
dialectCfg: this.dialectCfg,
|
|
20299
20504
|
params: this.params,
|
|
20300
|
-
layout: new
|
|
20505
|
+
layout: new GI(this.cfg.expressionWidth),
|
|
20301
20506
|
inline: !0
|
|
20302
20507
|
}).format(E);
|
|
20303
20508
|
} catch (R) {
|
|
20304
|
-
if (R instanceof
|
|
20509
|
+
if (R instanceof kE) {
|
|
20305
20510
|
this.params.setPositionalParameterIndex(e);
|
|
20306
20511
|
return;
|
|
20307
20512
|
} else
|
|
@@ -20310,36 +20515,36 @@ class nE {
|
|
|
20310
20515
|
}
|
|
20311
20516
|
formatKeywordNode(E) {
|
|
20312
20517
|
switch (E.tokenType) {
|
|
20313
|
-
case
|
|
20518
|
+
case D.RESERVED_JOIN:
|
|
20314
20519
|
return this.formatJoin(E);
|
|
20315
|
-
case
|
|
20316
|
-
case
|
|
20317
|
-
case
|
|
20520
|
+
case D.AND:
|
|
20521
|
+
case D.OR:
|
|
20522
|
+
case D.XOR:
|
|
20318
20523
|
return this.formatLogicalOperator(E);
|
|
20319
20524
|
default:
|
|
20320
20525
|
return this.formatKeyword(E);
|
|
20321
20526
|
}
|
|
20322
20527
|
}
|
|
20323
20528
|
formatJoin(E) {
|
|
20324
|
-
j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(
|
|
20529
|
+
j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E), o.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E), o.SPACE);
|
|
20325
20530
|
}
|
|
20326
20531
|
formatKeyword(E) {
|
|
20327
|
-
this.layout.add(this.showKw(E),
|
|
20532
|
+
this.layout.add(this.showKw(E), o.SPACE);
|
|
20328
20533
|
}
|
|
20329
20534
|
formatLogicalOperator(E) {
|
|
20330
|
-
this.cfg.logicalOperatorNewline === "before" ? j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(
|
|
20535
|
+
this.cfg.logicalOperatorNewline === "before" ? j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E), o.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(o.NEWLINE, o.INDENT, this.showKw(E), o.SPACE) : this.layout.add(this.showKw(E), o.NEWLINE, o.INDENT);
|
|
20331
20536
|
}
|
|
20332
20537
|
formatDataType(E) {
|
|
20333
|
-
this.layout.add(this.showDataType(E),
|
|
20538
|
+
this.layout.add(this.showDataType(E), o.SPACE);
|
|
20334
20539
|
}
|
|
20335
20540
|
showKw(E) {
|
|
20336
|
-
return
|
|
20541
|
+
return xT(E.tokenType) ? JT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
|
|
20337
20542
|
}
|
|
20338
20543
|
// Like showKw(), but skips tabular formatting
|
|
20339
20544
|
showNonTabularKw(E) {
|
|
20340
20545
|
switch (this.cfg.keywordCase) {
|
|
20341
20546
|
case "preserve":
|
|
20342
|
-
return
|
|
20547
|
+
return IE(E.raw);
|
|
20343
20548
|
case "upper":
|
|
20344
20549
|
return E.text;
|
|
20345
20550
|
case "lower":
|
|
@@ -20347,13 +20552,13 @@ class nE {
|
|
|
20347
20552
|
}
|
|
20348
20553
|
}
|
|
20349
20554
|
showFunctionKw(E) {
|
|
20350
|
-
return
|
|
20555
|
+
return xT(E.tokenType) ? JT(this.showNonTabularFunctionKw(E), this.cfg.indentStyle) : this.showNonTabularFunctionKw(E);
|
|
20351
20556
|
}
|
|
20352
20557
|
// Like showFunctionKw(), but skips tabular formatting
|
|
20353
20558
|
showNonTabularFunctionKw(E) {
|
|
20354
20559
|
switch (this.cfg.functionCase) {
|
|
20355
20560
|
case "preserve":
|
|
20356
|
-
return
|
|
20561
|
+
return IE(E.raw);
|
|
20357
20562
|
case "upper":
|
|
20358
20563
|
return E.text;
|
|
20359
20564
|
case "lower":
|
|
@@ -20375,7 +20580,7 @@ class nE {
|
|
|
20375
20580
|
showDataType(E) {
|
|
20376
20581
|
switch (this.cfg.dataTypeCase) {
|
|
20377
20582
|
case "preserve":
|
|
20378
|
-
return
|
|
20583
|
+
return IE(E.raw);
|
|
20379
20584
|
case "upper":
|
|
20380
20585
|
return E.text;
|
|
20381
20586
|
case "lower":
|
|
@@ -20383,9 +20588,9 @@ class nE {
|
|
|
20383
20588
|
}
|
|
20384
20589
|
}
|
|
20385
20590
|
}
|
|
20386
|
-
class
|
|
20591
|
+
class mI {
|
|
20387
20592
|
constructor(E, e) {
|
|
20388
|
-
this.dialect = E, this.cfg = e, this.params = new
|
|
20593
|
+
this.dialect = E, this.cfg = e, this.params = new AI(this.cfg.params);
|
|
20389
20594
|
}
|
|
20390
20595
|
/**
|
|
20391
20596
|
* Formats an SQL query.
|
|
@@ -20397,25 +20602,25 @@ class mN {
|
|
|
20397
20602
|
return this.formatAst(e).trimEnd();
|
|
20398
20603
|
}
|
|
20399
20604
|
parse(E) {
|
|
20400
|
-
return
|
|
20605
|
+
return UI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
|
|
20401
20606
|
}
|
|
20402
20607
|
formatAst(E) {
|
|
20403
20608
|
return E.map((e) => this.formatStatement(e)).join(`
|
|
20404
20609
|
`.repeat(this.cfg.linesBetweenQueries + 1));
|
|
20405
20610
|
}
|
|
20406
20611
|
formatStatement(E) {
|
|
20407
|
-
const e = new
|
|
20612
|
+
const e = new CE({
|
|
20408
20613
|
cfg: this.cfg,
|
|
20409
20614
|
dialectCfg: this.dialect.formatOptions,
|
|
20410
20615
|
params: this.params,
|
|
20411
|
-
layout: new
|
|
20616
|
+
layout: new ne(new Ce(RI(this.cfg)))
|
|
20412
20617
|
}).format(E.children);
|
|
20413
|
-
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? e.add(
|
|
20618
|
+
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? e.add(o.NEWLINE, ";") : e.add(o.NO_NEWLINE, ";")), e.toString();
|
|
20414
20619
|
}
|
|
20415
20620
|
}
|
|
20416
20621
|
class tE extends Error {
|
|
20417
20622
|
}
|
|
20418
|
-
function
|
|
20623
|
+
function dI(T) {
|
|
20419
20624
|
const E = [
|
|
20420
20625
|
"multilineLists",
|
|
20421
20626
|
"newlineBeforeOpenParen",
|
|
@@ -20429,17 +20634,17 @@ function dN(T) {
|
|
|
20429
20634
|
throw new tE(`${e} config is no more supported.`);
|
|
20430
20635
|
if (T.expressionWidth <= 0)
|
|
20431
20636
|
throw new tE(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
20432
|
-
if (T.params && !
|
|
20637
|
+
if (T.params && !HI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !pI(T.paramTypes))
|
|
20433
20638
|
throw new tE("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
20434
20639
|
return T;
|
|
20435
20640
|
}
|
|
20436
|
-
function
|
|
20641
|
+
function HI(T) {
|
|
20437
20642
|
return (T instanceof Array ? T : Object.values(T)).every((e) => typeof e == "string");
|
|
20438
20643
|
}
|
|
20439
|
-
function
|
|
20644
|
+
function pI(T) {
|
|
20440
20645
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
20441
20646
|
}
|
|
20442
|
-
var
|
|
20647
|
+
var BI = function(T, E) {
|
|
20443
20648
|
var e = {};
|
|
20444
20649
|
for (var R in T) Object.prototype.hasOwnProperty.call(T, R) && E.indexOf(R) < 0 && (e[R] = T[R]);
|
|
20445
20650
|
if (T != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -20447,7 +20652,7 @@ var pN = function(T, E) {
|
|
|
20447
20652
|
E.indexOf(R[A]) < 0 && Object.prototype.propertyIsEnumerable.call(T, R[A]) && (e[R[A]] = T[R[A]]);
|
|
20448
20653
|
return e;
|
|
20449
20654
|
};
|
|
20450
|
-
const
|
|
20655
|
+
const Le = {
|
|
20451
20656
|
bigquery: "bigquery",
|
|
20452
20657
|
db2: "db2",
|
|
20453
20658
|
db2i: "db2i",
|
|
@@ -20468,7 +20673,7 @@ const ne = {
|
|
|
20468
20673
|
tsql: "transactsql",
|
|
20469
20674
|
singlestoredb: "singlestoredb",
|
|
20470
20675
|
snowflake: "snowflake"
|
|
20471
|
-
},
|
|
20676
|
+
}, FI = Object.keys(Le), YI = {
|
|
20472
20677
|
tabWidth: 2,
|
|
20473
20678
|
useTabs: !1,
|
|
20474
20679
|
keywordCase: "preserve",
|
|
@@ -20481,27 +20686,27 @@ const ne = {
|
|
|
20481
20686
|
linesBetweenQueries: 1,
|
|
20482
20687
|
denseOperators: !1,
|
|
20483
20688
|
newlineBeforeSemicolon: !1
|
|
20484
|
-
},
|
|
20485
|
-
if (typeof E.language == "string" && !
|
|
20689
|
+
}, fI = (T, E = {}) => {
|
|
20690
|
+
if (typeof E.language == "string" && !FI.includes(E.language))
|
|
20486
20691
|
throw new tE(`Unsupported SQL dialect: ${E.language}`);
|
|
20487
|
-
const e =
|
|
20488
|
-
return
|
|
20489
|
-
},
|
|
20490
|
-
var { dialect: e } = E, R =
|
|
20692
|
+
const e = Le[E.language || "sql"];
|
|
20693
|
+
return hI(T, Object.assign(Object.assign({}, E), { dialect: XN[e] }));
|
|
20694
|
+
}, hI = (T, E) => {
|
|
20695
|
+
var { dialect: e } = E, R = BI(E, ["dialect"]);
|
|
20491
20696
|
if (typeof T != "string")
|
|
20492
20697
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
|
|
20493
|
-
const A =
|
|
20494
|
-
return new
|
|
20698
|
+
const A = dI(Object.assign(Object.assign({}, YI), R));
|
|
20699
|
+
return new mI(EI(e), A).format(T);
|
|
20495
20700
|
};
|
|
20496
|
-
function
|
|
20701
|
+
function VI(T) {
|
|
20497
20702
|
let E = 0;
|
|
20498
20703
|
return E += (T.measures?.length || 0) * 1, E += (T.dimensions?.length || 0) * 1, E += (T.filters?.length || 0) * 2, E += (T.timeDimensions?.length || 0) * 3, E <= 5 ? "low" : E <= 15 ? "medium" : "high";
|
|
20499
20704
|
}
|
|
20500
|
-
function
|
|
20705
|
+
function bI() {
|
|
20501
20706
|
const T = Date.now(), E = Math.random().toString(36).substring(2, 9);
|
|
20502
20707
|
return `${T}-${E}`;
|
|
20503
20708
|
}
|
|
20504
|
-
function
|
|
20709
|
+
function WI(T) {
|
|
20505
20710
|
const E = T.dimensions || [], e = T.timeDimensions || [], R = T.measures || [];
|
|
20506
20711
|
return {
|
|
20507
20712
|
sortedDimensions: E,
|
|
@@ -20526,7 +20731,7 @@ function bN(T) {
|
|
|
20526
20731
|
hasMultiStage: !1
|
|
20527
20732
|
};
|
|
20528
20733
|
}
|
|
20529
|
-
function
|
|
20734
|
+
function yI(T) {
|
|
20530
20735
|
if (T.hasExecutor()) {
|
|
20531
20736
|
const E = T.databaseExecutor;
|
|
20532
20737
|
if (E?.engineType)
|
|
@@ -20534,24 +20739,24 @@ function XN(T) {
|
|
|
20534
20739
|
}
|
|
20535
20740
|
return "postgres";
|
|
20536
20741
|
}
|
|
20537
|
-
async function
|
|
20742
|
+
async function KI(T, E, e) {
|
|
20538
20743
|
const R = e.validateQuery(T);
|
|
20539
20744
|
if (!R.isValid)
|
|
20540
20745
|
throw new Error(`Query validation failed: ${R.errors.join(", ")}`);
|
|
20541
20746
|
const A = /* @__PURE__ */ new Set();
|
|
20542
|
-
T.measures?.forEach((
|
|
20543
|
-
const
|
|
20544
|
-
A.add(
|
|
20545
|
-
}), T.dimensions?.forEach((
|
|
20546
|
-
const
|
|
20547
|
-
A.add(
|
|
20548
|
-
}), T.timeDimensions?.forEach((
|
|
20549
|
-
const
|
|
20550
|
-
A.add(
|
|
20551
|
-
}), T.filters?.forEach((
|
|
20552
|
-
if ("member" in
|
|
20553
|
-
const
|
|
20554
|
-
A.add(
|
|
20747
|
+
T.measures?.forEach((O) => {
|
|
20748
|
+
const N = O.split(".")[0];
|
|
20749
|
+
A.add(N);
|
|
20750
|
+
}), T.dimensions?.forEach((O) => {
|
|
20751
|
+
const N = O.split(".")[0];
|
|
20752
|
+
A.add(N);
|
|
20753
|
+
}), T.timeDimensions?.forEach((O) => {
|
|
20754
|
+
const N = O.dimension.split(".")[0];
|
|
20755
|
+
A.add(N);
|
|
20756
|
+
}), T.filters?.forEach((O) => {
|
|
20757
|
+
if ("member" in O) {
|
|
20758
|
+
const N = O.member.split(".")[0];
|
|
20759
|
+
A.add(N);
|
|
20555
20760
|
}
|
|
20556
20761
|
});
|
|
20557
20762
|
const S = A.size > 1;
|
|
@@ -20559,14 +20764,14 @@ async function KN(T, E, e) {
|
|
|
20559
20764
|
if (S)
|
|
20560
20765
|
I = await e.generateMultiCubeSQL(T, E);
|
|
20561
20766
|
else {
|
|
20562
|
-
const
|
|
20563
|
-
I = await e.generateSQL(
|
|
20767
|
+
const O = Array.from(A)[0];
|
|
20768
|
+
I = await e.generateSQL(O, T, E);
|
|
20564
20769
|
}
|
|
20565
|
-
const t = Array.from(A).map((
|
|
20566
|
-
cube:
|
|
20770
|
+
const t = Array.from(A).map((O) => ({
|
|
20771
|
+
cube: O,
|
|
20567
20772
|
query: {
|
|
20568
|
-
measures: T.measures?.filter((
|
|
20569
|
-
dimensions: T.dimensions?.filter((
|
|
20773
|
+
measures: T.measures?.filter((N) => N.startsWith(O + ".")) || [],
|
|
20774
|
+
dimensions: T.dimensions?.filter((N) => N.startsWith(O + ".")) || [],
|
|
20570
20775
|
filters: T.filters || [],
|
|
20571
20776
|
timeDimensions: T.timeDimensions || [],
|
|
20572
20777
|
order: T.order || {},
|
|
@@ -20574,6 +20779,12 @@ async function KN(T, E, e) {
|
|
|
20574
20779
|
offset: T.offset
|
|
20575
20780
|
}
|
|
20576
20781
|
}));
|
|
20782
|
+
let s;
|
|
20783
|
+
try {
|
|
20784
|
+
s = e.analyzeQuery(T, E);
|
|
20785
|
+
} catch (O) {
|
|
20786
|
+
console.warn("Query analysis failed:", O);
|
|
20787
|
+
}
|
|
20577
20788
|
return {
|
|
20578
20789
|
queryType: "regularQuery",
|
|
20579
20790
|
normalizedQueries: t,
|
|
@@ -20587,15 +20798,17 @@ async function KN(T, E, e) {
|
|
|
20587
20798
|
sql: [I.sql],
|
|
20588
20799
|
params: I.params || []
|
|
20589
20800
|
},
|
|
20590
|
-
complexity:
|
|
20801
|
+
complexity: VI(T),
|
|
20591
20802
|
valid: !0,
|
|
20592
20803
|
cubesUsed: Array.from(A),
|
|
20593
20804
|
joinType: S ? "multi_cube_join" : "single_cube",
|
|
20594
|
-
query: T
|
|
20805
|
+
query: T,
|
|
20806
|
+
// Query analysis for debugging and transparency
|
|
20807
|
+
analysis: s
|
|
20595
20808
|
};
|
|
20596
20809
|
}
|
|
20597
|
-
function
|
|
20598
|
-
const R =
|
|
20810
|
+
function XI(T, E, e) {
|
|
20811
|
+
const R = yI(e), A = bI(), S = (/* @__PURE__ */ new Date()).toISOString(), I = WI(T);
|
|
20599
20812
|
return {
|
|
20600
20813
|
queryType: "regularQuery",
|
|
20601
20814
|
results: [{
|
|
@@ -20619,9 +20832,9 @@ function yN(T, E, e) {
|
|
|
20619
20832
|
slowQuery: !1
|
|
20620
20833
|
};
|
|
20621
20834
|
}
|
|
20622
|
-
function
|
|
20835
|
+
function vT(T, E) {
|
|
20623
20836
|
try {
|
|
20624
|
-
return
|
|
20837
|
+
return fI(T, {
|
|
20625
20838
|
language: {
|
|
20626
20839
|
postgres: "postgresql",
|
|
20627
20840
|
mysql: "mysql",
|
|
@@ -20637,29 +20850,29 @@ function xT(T, E) {
|
|
|
20637
20850
|
return console.warn("SQL formatting failed:", e), T;
|
|
20638
20851
|
}
|
|
20639
20852
|
}
|
|
20640
|
-
function $
|
|
20853
|
+
function $I(T, E) {
|
|
20641
20854
|
return {
|
|
20642
20855
|
sql: E.sql,
|
|
20643
20856
|
params: E.params || [],
|
|
20644
20857
|
query: T
|
|
20645
20858
|
};
|
|
20646
20859
|
}
|
|
20647
|
-
function
|
|
20860
|
+
function wI(T) {
|
|
20648
20861
|
return {
|
|
20649
20862
|
cubes: T
|
|
20650
20863
|
};
|
|
20651
20864
|
}
|
|
20652
|
-
function
|
|
20865
|
+
function JI(T, E = 500) {
|
|
20653
20866
|
return {
|
|
20654
20867
|
error: T instanceof Error ? T.message : T,
|
|
20655
20868
|
status: E
|
|
20656
20869
|
};
|
|
20657
20870
|
}
|
|
20658
|
-
async function
|
|
20871
|
+
async function xI(T, E, e) {
|
|
20659
20872
|
return { results: (await Promise.allSettled(
|
|
20660
20873
|
T.map(async (S) => {
|
|
20661
20874
|
const I = await e.executeMultiCubeQuery(S, E);
|
|
20662
|
-
return
|
|
20875
|
+
return XI(S, I, e);
|
|
20663
20876
|
})
|
|
20664
20877
|
)).map((S, I) => S.status === "fulfilled" ? {
|
|
20665
20878
|
success: !0,
|
|
@@ -20671,7 +20884,7 @@ async function xN(T, E, e) {
|
|
|
20671
20884
|
// Include the query that failed for debugging
|
|
20672
20885
|
}) };
|
|
20673
20886
|
}
|
|
20674
|
-
class
|
|
20887
|
+
class gI {
|
|
20675
20888
|
cubes = /* @__PURE__ */ new Map();
|
|
20676
20889
|
dbExecutor;
|
|
20677
20890
|
metadataCache;
|
|
@@ -20679,7 +20892,7 @@ class gN {
|
|
|
20679
20892
|
METADATA_CACHE_TTL = 300 * 1e3;
|
|
20680
20893
|
// 5 minutes in milliseconds
|
|
20681
20894
|
constructor(E) {
|
|
20682
|
-
E?.databaseExecutor ? this.dbExecutor = E.databaseExecutor : E?.drizzle && (this.dbExecutor =
|
|
20895
|
+
E?.databaseExecutor ? this.dbExecutor = E.databaseExecutor : E?.drizzle && (this.dbExecutor = LT(
|
|
20683
20896
|
E.drizzle,
|
|
20684
20897
|
E.schema,
|
|
20685
20898
|
E.engineType
|
|
@@ -20701,7 +20914,7 @@ class gN {
|
|
|
20701
20914
|
* Set Drizzle instance and schema directly
|
|
20702
20915
|
*/
|
|
20703
20916
|
setDrizzle(E, e, R) {
|
|
20704
|
-
this.dbExecutor =
|
|
20917
|
+
this.dbExecutor = LT(E, e, R);
|
|
20705
20918
|
}
|
|
20706
20919
|
/**
|
|
20707
20920
|
* Check if database executor is configured
|
|
@@ -20730,7 +20943,7 @@ class gN {
|
|
|
20730
20943
|
);
|
|
20731
20944
|
continue;
|
|
20732
20945
|
}
|
|
20733
|
-
const S =
|
|
20946
|
+
const S = ge(A.calculatedSql);
|
|
20734
20947
|
if (!S.isValid) {
|
|
20735
20948
|
e.push(
|
|
20736
20949
|
`Invalid calculatedSql syntax in '${E.name}.${R}': ${S.errors.join(", ")}`
|
|
@@ -20787,7 +21000,7 @@ ${e.join(`
|
|
|
20787
21000
|
async execute(E, e) {
|
|
20788
21001
|
if (!this.dbExecutor)
|
|
20789
21002
|
throw new Error("Database executor not configured");
|
|
20790
|
-
return new
|
|
21003
|
+
return new mE(this.dbExecutor).execute(this.cubes, E, e);
|
|
20791
21004
|
}
|
|
20792
21005
|
/**
|
|
20793
21006
|
* Execute a multi-cube query
|
|
@@ -20893,9 +21106,9 @@ ${e.join(`
|
|
|
20893
21106
|
throw new Error(`Cube '${E}' not found`);
|
|
20894
21107
|
if (!this.dbExecutor)
|
|
20895
21108
|
throw new Error("Database executor not configured");
|
|
20896
|
-
const I = await new
|
|
21109
|
+
const I = await new mE(this.dbExecutor).generateSQL(A, e, R), t = this.dbExecutor.getEngineType();
|
|
20897
21110
|
return {
|
|
20898
|
-
sql:
|
|
21111
|
+
sql: vT(I.sql, t),
|
|
20899
21112
|
params: I.params
|
|
20900
21113
|
};
|
|
20901
21114
|
}
|
|
@@ -20905,9 +21118,9 @@ ${e.join(`
|
|
|
20905
21118
|
async generateMultiCubeSQL(E, e) {
|
|
20906
21119
|
if (!this.dbExecutor)
|
|
20907
21120
|
throw new Error("Database executor not configured");
|
|
20908
|
-
const A = await new
|
|
21121
|
+
const A = await new mE(this.dbExecutor).generateMultiCubeSQL(this.cubes, E, e), S = this.dbExecutor.getEngineType();
|
|
20909
21122
|
return {
|
|
20910
|
-
sql:
|
|
21123
|
+
sql: vT(A.sql, S),
|
|
20911
21124
|
params: A.params
|
|
20912
21125
|
};
|
|
20913
21126
|
}
|
|
@@ -20948,10 +21161,25 @@ ${e.join(`
|
|
|
20948
21161
|
* Ensures all referenced cubes and fields exist
|
|
20949
21162
|
*/
|
|
20950
21163
|
validateQuery(E) {
|
|
20951
|
-
return
|
|
21164
|
+
return _e(this.cubes, E);
|
|
21165
|
+
}
|
|
21166
|
+
/**
|
|
21167
|
+
* Analyze query planning decisions for debugging and transparency
|
|
21168
|
+
* Returns detailed metadata about how the query would be planned
|
|
21169
|
+
* Used by the playground UI to help users understand query structure
|
|
21170
|
+
*/
|
|
21171
|
+
analyzeQuery(E, e) {
|
|
21172
|
+
if (!this.dbExecutor)
|
|
21173
|
+
throw new Error("Database executor not configured");
|
|
21174
|
+
const R = new Te(), A = {
|
|
21175
|
+
db: this.dbExecutor.db,
|
|
21176
|
+
schema: this.dbExecutor.schema,
|
|
21177
|
+
securityContext: e
|
|
21178
|
+
};
|
|
21179
|
+
return R.analyzeQueryPlan(this.cubes, E, A);
|
|
20952
21180
|
}
|
|
20953
21181
|
}
|
|
20954
|
-
function
|
|
21182
|
+
function _e(T, E) {
|
|
20955
21183
|
const e = [], R = /* @__PURE__ */ new Set();
|
|
20956
21184
|
if (E.measures)
|
|
20957
21185
|
for (const A of E.measures) {
|
|
@@ -21000,17 +21228,17 @@ function Le(T, E) {
|
|
|
21000
21228
|
}
|
|
21001
21229
|
if (E.filters)
|
|
21002
21230
|
for (const A of E.filters)
|
|
21003
|
-
|
|
21231
|
+
ie(A, T, e, R);
|
|
21004
21232
|
return R.size === 0 && e.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
21005
21233
|
isValid: e.length === 0,
|
|
21006
21234
|
errors: e
|
|
21007
21235
|
};
|
|
21008
21236
|
}
|
|
21009
|
-
function
|
|
21237
|
+
function ie(T, E, e, R) {
|
|
21010
21238
|
if ("and" in T || "or" in T) {
|
|
21011
21239
|
const t = T.and || T.or || [];
|
|
21012
21240
|
for (const s of t)
|
|
21013
|
-
|
|
21241
|
+
ie(s, E, e, R);
|
|
21014
21242
|
return;
|
|
21015
21243
|
}
|
|
21016
21244
|
if (!("member" in T)) {
|
|
@@ -21030,13 +21258,13 @@ function _e(T, E, e, R) {
|
|
|
21030
21258
|
}
|
|
21031
21259
|
!I.dimensions[S] && !I.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
|
|
21032
21260
|
}
|
|
21033
|
-
new
|
|
21261
|
+
new gI();
|
|
21034
21262
|
export {
|
|
21035
|
-
|
|
21036
|
-
|
|
21037
|
-
$
|
|
21038
|
-
|
|
21039
|
-
|
|
21040
|
-
|
|
21041
|
-
|
|
21263
|
+
gI as S,
|
|
21264
|
+
wI as a,
|
|
21265
|
+
$I as b,
|
|
21266
|
+
KI as c,
|
|
21267
|
+
JI as d,
|
|
21268
|
+
XI as f,
|
|
21269
|
+
xI as h
|
|
21042
21270
|
};
|