@uwdata/mosaic-sql 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ast/aggregate.d.ts +0 -4
- package/dist/src/ast/aggregate.d.ts.map +1 -1
- package/dist/src/ast/aggregate.js +0 -15
- package/dist/src/ast/aggregate.js.map +1 -1
- package/dist/src/ast/between-op.d.ts +0 -8
- package/dist/src/ast/between-op.d.ts.map +1 -1
- package/dist/src/ast/between-op.js +0 -12
- package/dist/src/ast/between-op.js.map +1 -1
- package/dist/src/ast/binary-op.d.ts +0 -4
- package/dist/src/ast/binary-op.d.ts.map +1 -1
- package/dist/src/ast/binary-op.js +0 -6
- package/dist/src/ast/binary-op.js.map +1 -1
- package/dist/src/ast/case.d.ts +0 -8
- package/dist/src/ast/case.d.ts.map +1 -1
- package/dist/src/ast/case.js +0 -16
- package/dist/src/ast/case.js.map +1 -1
- package/dist/src/ast/cast.d.ts +0 -4
- package/dist/src/ast/cast.d.ts.map +1 -1
- package/dist/src/ast/cast.js +0 -7
- package/dist/src/ast/cast.js.map +1 -1
- package/dist/src/ast/collate.d.ts +0 -4
- package/dist/src/ast/collate.d.ts.map +1 -1
- package/dist/src/ast/collate.js +0 -6
- package/dist/src/ast/collate.js.map +1 -1
- package/dist/src/ast/column-ref.d.ts +0 -4
- package/dist/src/ast/column-ref.d.ts.map +1 -1
- package/dist/src/ast/column-ref.js +0 -10
- package/dist/src/ast/column-ref.js.map +1 -1
- package/dist/src/ast/fragment.d.ts +0 -4
- package/dist/src/ast/fragment.d.ts.map +1 -1
- package/dist/src/ast/fragment.js +0 -6
- package/dist/src/ast/fragment.js.map +1 -1
- package/dist/src/ast/from.d.ts +10 -3
- package/dist/src/ast/from.d.ts.map +1 -1
- package/dist/src/ast/from.js +11 -12
- package/dist/src/ast/from.js.map +1 -1
- package/dist/src/ast/function.d.ts +0 -4
- package/dist/src/ast/function.d.ts.map +1 -1
- package/dist/src/ast/function.js +0 -7
- package/dist/src/ast/function.js.map +1 -1
- package/dist/src/ast/in-op.d.ts +0 -4
- package/dist/src/ast/in-op.d.ts.map +1 -1
- package/dist/src/ast/in-op.js +0 -6
- package/dist/src/ast/in-op.js.map +1 -1
- package/dist/src/ast/interval.d.ts +0 -4
- package/dist/src/ast/interval.d.ts.map +1 -1
- package/dist/src/ast/interval.js +0 -6
- package/dist/src/ast/interval.js.map +1 -1
- package/dist/src/ast/join.d.ts +45 -0
- package/dist/src/ast/join.d.ts.map +1 -0
- package/dist/src/ast/join.js +47 -0
- package/dist/src/ast/join.js.map +1 -0
- package/dist/src/ast/list.d.ts +0 -4
- package/dist/src/ast/list.d.ts.map +1 -1
- package/dist/src/ast/list.js +0 -6
- package/dist/src/ast/list.js.map +1 -1
- package/dist/src/ast/literal.d.ts +0 -4
- package/dist/src/ast/literal.d.ts.map +1 -1
- package/dist/src/ast/literal.js +0 -6
- package/dist/src/ast/literal.js.map +1 -1
- package/dist/src/ast/logical-op.d.ts +0 -4
- package/dist/src/ast/logical-op.d.ts.map +1 -1
- package/dist/src/ast/logical-op.js +0 -9
- package/dist/src/ast/logical-op.js.map +1 -1
- package/dist/src/ast/node.d.ts +13 -0
- package/dist/src/ast/node.d.ts.map +1 -1
- package/dist/src/ast/node.js +25 -3
- package/dist/src/ast/node.js.map +1 -1
- package/dist/src/ast/order-by.d.ts +0 -4
- package/dist/src/ast/order-by.d.ts.map +1 -1
- package/dist/src/ast/order-by.js +0 -13
- package/dist/src/ast/order-by.js.map +1 -1
- package/dist/src/ast/param.d.ts +0 -4
- package/dist/src/ast/param.d.ts.map +1 -1
- package/dist/src/ast/param.js +0 -7
- package/dist/src/ast/param.js.map +1 -1
- package/dist/src/ast/query.d.ts +2 -14
- package/dist/src/ast/query.d.ts.map +1 -1
- package/dist/src/ast/query.js +14 -91
- package/dist/src/ast/query.js.map +1 -1
- package/dist/src/ast/sample.d.ts +0 -4
- package/dist/src/ast/sample.d.ts.map +1 -1
- package/dist/src/ast/sample.js +0 -9
- package/dist/src/ast/sample.js.map +1 -1
- package/dist/src/ast/select.d.ts +0 -4
- package/dist/src/ast/select.d.ts.map +1 -1
- package/dist/src/ast/select.js +0 -16
- package/dist/src/ast/select.js.map +1 -1
- package/dist/src/ast/subquery.d.ts +0 -4
- package/dist/src/ast/subquery.d.ts.map +1 -1
- package/dist/src/ast/subquery.js +0 -6
- package/dist/src/ast/subquery.js.map +1 -1
- package/dist/src/ast/table-ref.d.ts +0 -4
- package/dist/src/ast/table-ref.d.ts.map +1 -1
- package/dist/src/ast/table-ref.js +0 -7
- package/dist/src/ast/table-ref.js.map +1 -1
- package/dist/src/ast/unary-op.d.ts +0 -8
- package/dist/src/ast/unary-op.d.ts.map +1 -1
- package/dist/src/ast/unary-op.js +0 -12
- package/dist/src/ast/unary-op.js.map +1 -1
- package/dist/src/ast/unnest.d.ts +0 -4
- package/dist/src/ast/unnest.d.ts.map +1 -1
- package/dist/src/ast/unnest.js +0 -8
- package/dist/src/ast/unnest.js.map +1 -1
- package/dist/src/ast/verbatim.d.ts +0 -4
- package/dist/src/ast/verbatim.d.ts.map +1 -1
- package/dist/src/ast/verbatim.js +0 -6
- package/dist/src/ast/verbatim.js.map +1 -1
- package/dist/src/ast/window-frame.d.ts +0 -8
- package/dist/src/ast/window-frame.d.ts.map +1 -1
- package/dist/src/ast/window-frame.js +1 -29
- package/dist/src/ast/window-frame.js.map +1 -1
- package/dist/src/ast/window.d.ts +0 -16
- package/dist/src/ast/window.d.ts.map +1 -1
- package/dist/src/ast/window.js +0 -39
- package/dist/src/ast/window.js.map +1 -1
- package/dist/src/ast/with.d.ts +0 -4
- package/dist/src/ast/with.d.ts.map +1 -1
- package/dist/src/ast/with.js +0 -10
- package/dist/src/ast/with.js.map +1 -1
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +2 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/functions/from.d.ts +11 -0
- package/dist/src/functions/from.d.ts.map +1 -0
- package/dist/src/functions/from.js +12 -0
- package/dist/src/functions/from.js.map +1 -0
- package/dist/src/functions/join.d.ts +49 -0
- package/dist/src/functions/join.d.ts.map +1 -0
- package/dist/src/functions/join.js +50 -0
- package/dist/src/functions/join.js.map +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/init.d.ts +2 -0
- package/dist/src/init.d.ts.map +1 -0
- package/dist/src/init.js +5 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/transforms/filter-query.d.ts.map +1 -1
- package/dist/src/transforms/filter-query.js +2 -0
- package/dist/src/transforms/filter-query.js.map +1 -1
- package/dist/src/visit/codegen/duckdb.d.ts +49 -0
- package/dist/src/visit/codegen/duckdb.d.ts.map +1 -0
- package/dist/src/visit/codegen/duckdb.js +332 -0
- package/dist/src/visit/codegen/duckdb.js.map +1 -0
- package/dist/src/visit/codegen/sql.d.ts +60 -0
- package/dist/src/visit/codegen/sql.d.ts.map +1 -0
- package/dist/src/visit/codegen/sql.js +85 -0
- package/dist/src/visit/codegen/sql.js.map +1 -0
- package/dist/src/visit/duckdb-visitor.d.ts +50 -0
- package/dist/src/visit/duckdb-visitor.d.ts.map +1 -0
- package/dist/src/visit/duckdb-visitor.js +350 -0
- package/dist/src/visit/duckdb-visitor.js.map +1 -0
- package/dist/src/visit/recurse.d.ts.map +1 -1
- package/dist/src/visit/recurse.js +2 -1
- package/dist/src/visit/recurse.js.map +1 -1
- package/dist/src/visit/to-string-visitor.d.ts +60 -0
- package/dist/src/visit/to-string-visitor.d.ts.map +1 -0
- package/dist/src/visit/to-string-visitor.js +80 -0
- package/dist/src/visit/to-string-visitor.js.map +1 -0
- package/package.json +2 -2
- package/src/ast/aggregate.ts +0 -16
- package/src/ast/between-op.ts +0 -14
- package/src/ast/binary-op.ts +0 -7
- package/src/ast/case.ts +0 -18
- package/src/ast/cast.ts +0 -8
- package/src/ast/collate.ts +0 -7
- package/src/ast/column-ref.ts +0 -11
- package/src/ast/fragment.ts +0 -7
- package/src/ast/from.ts +12 -12
- package/src/ast/function.ts +0 -8
- package/src/ast/in-op.ts +0 -7
- package/src/ast/interval.ts +0 -7
- package/src/ast/join.ts +66 -0
- package/src/ast/list.ts +0 -7
- package/src/ast/literal.ts +0 -7
- package/src/ast/logical-op.ts +0 -10
- package/src/ast/node.ts +30 -3
- package/src/ast/order-by.ts +0 -14
- package/src/ast/param.ts +0 -8
- package/src/ast/query.ts +14 -102
- package/src/ast/sample.ts +0 -10
- package/src/ast/select.ts +0 -18
- package/src/ast/subquery.ts +0 -7
- package/src/ast/table-ref.ts +0 -8
- package/src/ast/unary-op.ts +0 -14
- package/src/ast/unnest.ts +0 -9
- package/src/ast/verbatim.ts +0 -7
- package/src/ast/window-frame.ts +1 -32
- package/src/ast/window.ts +0 -43
- package/src/ast/with.ts +0 -11
- package/src/constants.ts +2 -0
- package/src/functions/from.ts +18 -0
- package/src/functions/join.ts +101 -0
- package/src/index.ts +9 -1
- package/src/init.ts +5 -0
- package/src/transforms/filter-query.ts +2 -0
- package/src/visit/codegen/duckdb.ts +444 -0
- package/src/visit/codegen/sql.ts +213 -0
- package/src/visit/recurse.ts +2 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SampleClauseNode } from './sample.js';
|
|
2
|
+
import { ColumnRefNode } from './column-ref.js';
|
|
3
|
+
import { FromNode } from './from.js';
|
|
4
|
+
import { ExprNode } from './node.js';
|
|
5
|
+
import { TableRefNode } from './table-ref.js';
|
|
6
|
+
/** The join variant. Determines what kind of join is performed. */
|
|
7
|
+
export type JoinVariant = 'REGULAR' | 'CROSS' | 'NATURAL' | 'POSITIONAL' | 'ASOF';
|
|
8
|
+
/** The join type. Determines which values are included in the join output. */
|
|
9
|
+
export type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'SEMI' | 'ANTI';
|
|
10
|
+
export declare class JoinNode extends FromNode {
|
|
11
|
+
/** The left table to join. */
|
|
12
|
+
readonly left: FromNode | TableRefNode;
|
|
13
|
+
/** The right table to join. */
|
|
14
|
+
readonly right: FromNode | TableRefNode;
|
|
15
|
+
/** The join variant (REGULAR, CROSS, NATURAL, POSITIONAL, ASOF). */
|
|
16
|
+
readonly joinVariant: JoinVariant;
|
|
17
|
+
/** The join type (INNER, LEFT, RIGHT, FULL, SEMI, ANTI). */
|
|
18
|
+
readonly joinType: JoinType;
|
|
19
|
+
/**
|
|
20
|
+
* The join condition as a boolean expression.
|
|
21
|
+
* If specified, *using* should be `undefined`.
|
|
22
|
+
*/
|
|
23
|
+
readonly condition?: ExprNode;
|
|
24
|
+
/**
|
|
25
|
+
* The join condition as shared columns to match on.
|
|
26
|
+
* If specified, *condition* should be `undefined`.
|
|
27
|
+
*/
|
|
28
|
+
readonly using?: ColumnRefNode[];
|
|
29
|
+
/** A table sample to apply to join output. */
|
|
30
|
+
readonly sample?: SampleClauseNode;
|
|
31
|
+
/**
|
|
32
|
+
* Instantiate a join node.
|
|
33
|
+
* @param left The left table to join.
|
|
34
|
+
* @param right The right table to join.
|
|
35
|
+
* @param variant The join variant (REGULAR, CROSS, NATURAL, POSITIONAL, ASOF).
|
|
36
|
+
* @param type The join type (INNER, LEFT, RIGHT, FULL, SEMI, ANTI).
|
|
37
|
+
* @param condition The join condition as a boolean expression.
|
|
38
|
+
* If specified, *using* should be `undefined`.
|
|
39
|
+
* @param using The join condition as shared columns to match on.
|
|
40
|
+
* If specified, *condition* should be `undefined`.
|
|
41
|
+
* @param sample A table sample to apply to join output.
|
|
42
|
+
*/
|
|
43
|
+
constructor(left: FromNode | TableRefNode, right: FromNode | TableRefNode, variant?: JoinVariant, type?: JoinType, condition?: ExprNode, using?: ColumnRefNode[], sample?: SampleClauseNode);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.d.ts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EAAE,aAAa,EAAE,EACvB,MAAM,CAAC,EAAE,gBAAgB;CAW5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { JOIN_CLAUSE } from '../constants.js';
|
|
2
|
+
import { FromNode } from './from.js';
|
|
3
|
+
export class JoinNode extends FromNode {
|
|
4
|
+
/** The left table to join. */
|
|
5
|
+
left;
|
|
6
|
+
/** The right table to join. */
|
|
7
|
+
right;
|
|
8
|
+
/** The join variant (REGULAR, CROSS, NATURAL, POSITIONAL, ASOF). */
|
|
9
|
+
joinVariant;
|
|
10
|
+
/** The join type (INNER, LEFT, RIGHT, FULL, SEMI, ANTI). */
|
|
11
|
+
joinType;
|
|
12
|
+
/**
|
|
13
|
+
* The join condition as a boolean expression.
|
|
14
|
+
* If specified, *using* should be `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
condition;
|
|
17
|
+
/**
|
|
18
|
+
* The join condition as shared columns to match on.
|
|
19
|
+
* If specified, *condition* should be `undefined`.
|
|
20
|
+
*/
|
|
21
|
+
using;
|
|
22
|
+
/** A table sample to apply to join output. */
|
|
23
|
+
sample;
|
|
24
|
+
/**
|
|
25
|
+
* Instantiate a join node.
|
|
26
|
+
* @param left The left table to join.
|
|
27
|
+
* @param right The right table to join.
|
|
28
|
+
* @param variant The join variant (REGULAR, CROSS, NATURAL, POSITIONAL, ASOF).
|
|
29
|
+
* @param type The join type (INNER, LEFT, RIGHT, FULL, SEMI, ANTI).
|
|
30
|
+
* @param condition The join condition as a boolean expression.
|
|
31
|
+
* If specified, *using* should be `undefined`.
|
|
32
|
+
* @param using The join condition as shared columns to match on.
|
|
33
|
+
* If specified, *condition* should be `undefined`.
|
|
34
|
+
* @param sample A table sample to apply to join output.
|
|
35
|
+
*/
|
|
36
|
+
constructor(left, right, variant = 'NATURAL', type = 'INNER', condition, using, sample) {
|
|
37
|
+
super(JOIN_CLAUSE);
|
|
38
|
+
this.left = left;
|
|
39
|
+
this.right = right;
|
|
40
|
+
this.joinVariant = variant;
|
|
41
|
+
this.joinType = type;
|
|
42
|
+
this.condition = condition;
|
|
43
|
+
this.using = using;
|
|
44
|
+
this.sample = sample;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../../src/ast/join.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAUrC,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,8BAA8B;IACrB,IAAI,CAA0B;IACvC,+BAA+B;IACtB,KAAK,CAA0B;IACxC,oEAAoE;IAC3D,WAAW,CAAc;IAClC,4DAA4D;IACnD,QAAQ,CAAW;IAC5B;;;OAGG;IACM,SAAS,CAAY;IAC9B;;;OAGG;IACM,KAAK,CAAmB;IACjC,8CAA8C;IACrC,MAAM,CAAoB;IAEnC;;;;;;;;;;;OAWG;IACH,YACE,IAA6B,EAC7B,KAA8B,EAC9B,UAAuB,SAAS,EAChC,OAAiB,OAAO,EACxB,SAAoB,EACpB,KAAuB,EACvB,MAAyB;QAEzB,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
package/dist/src/ast/list.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/ast/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,QAAS,SAAQ,QAAQ;IACpC,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAE5B;;;OAGG;gBACS,MAAM,EAAE,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/ast/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,QAAS,SAAQ,QAAQ;IACpC,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAE5B;;;OAGG;gBACS,MAAM,EAAE,QAAQ,EAAE;CAI/B"}
|
package/dist/src/ast/list.js
CHANGED
package/dist/src/ast/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/ast/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,2BAA2B;IAClB,MAAM,CAAa;IAE5B;;;OAGG;IACH,YAAY,MAAkB;QAC5B,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/ast/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,2BAA2B;IAClB,MAAM,CAAa;IAE5B;;;OAGG;IACH,YAAY,MAAkB;QAC5B,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -7,10 +7,6 @@ export declare class LiteralNode extends ExprNode {
|
|
|
7
7
|
* @param value The literal value.
|
|
8
8
|
*/
|
|
9
9
|
constructor(value: unknown);
|
|
10
|
-
/**
|
|
11
|
-
* Generate a SQL query string for this node.
|
|
12
|
-
*/
|
|
13
|
-
toString(): string;
|
|
14
10
|
}
|
|
15
11
|
export declare function literalToSQL(value: unknown): string;
|
|
16
12
|
//# sourceMappingURL=literal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../src/ast/literal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,WAAY,SAAQ,QAAQ;IACvC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;OAGG;gBACS,KAAK,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../src/ast/literal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,WAAY,SAAQ,QAAQ;IACvC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;OAGG;gBACS,KAAK,EAAE,OAAO;CAI3B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,UA2B1C"}
|
package/dist/src/ast/literal.js
CHANGED
|
@@ -11,12 +11,6 @@ export class LiteralNode extends ExprNode {
|
|
|
11
11
|
super(LITERAL);
|
|
12
12
|
this.value = value;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Generate a SQL query string for this node.
|
|
16
|
-
*/
|
|
17
|
-
toString() {
|
|
18
|
-
return literalToSQL(this.value);
|
|
19
|
-
}
|
|
20
14
|
}
|
|
21
15
|
export function literalToSQL(value) {
|
|
22
16
|
switch (typeof value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../src/ast/literal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,yBAAyB;IAChB,KAAK,CAAU;IAExB;;;OAGG;IACH,YAAY,KAAc;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../src/ast/literal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,yBAAyB;IAChB,KAAK,CAAU;IAExB;;;OAGG;IACH,YAAY,KAAc;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACtD,KAAK,QAAQ;YACX,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;QAC5C,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAClC;YACE,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,OAAO,MAAM,CAAC;YAChB,CAAC;iBAAM,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;gBACjC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC;gBAClB,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBAAE,OAAO,MAAM,CAAC;gBACpC,MAAM,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;gBACjC,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;gBAC7B,OAAO,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC7B,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAC,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW;oBACvC,CAAC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,YAAY;YACrC,CAAC;iBAAM,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;gBACnC,OAAO,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,oCAAoC;gBACpC,OAAO,GAAG,KAAK,EAAE,CAAC;YACpB,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -10,10 +10,6 @@ export declare class LogicalOpNode<T extends ExprNode> extends ExprNode {
|
|
|
10
10
|
* @param clauses The input clause expressions.
|
|
11
11
|
*/
|
|
12
12
|
constructor(op: string, clauses: T[]);
|
|
13
|
-
/**
|
|
14
|
-
* Generate a SQL query string for this node.
|
|
15
|
-
*/
|
|
16
|
-
toString(): string;
|
|
17
13
|
}
|
|
18
14
|
export declare class AndNode<T extends ExprNode> extends LogicalOpNode<T> {
|
|
19
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logical-op.d.ts","sourceRoot":"","sources":["../../../src/ast/logical-op.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,aAAa,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,QAAQ;IAC7D,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IAEtB;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"logical-op.d.ts","sourceRoot":"","sources":["../../../src/ast/logical-op.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,aAAa,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,QAAQ;IAC7D,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IAEtB;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE;CAKrC;AAED,qBAAa,OAAO,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC/D;;;OAGG;gBACS,OAAO,EAAE,CAAC,EAAE;CAGzB;AAED,qBAAa,MAAM,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC9D;;;OAGG;gBACS,OAAO,EAAE,CAAC,EAAE;CAGzB"}
|
|
@@ -15,15 +15,6 @@ export class LogicalOpNode extends ExprNode {
|
|
|
15
15
|
this.op = op;
|
|
16
16
|
this.clauses = clauses;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Generate a SQL query string for this node.
|
|
20
|
-
*/
|
|
21
|
-
toString() {
|
|
22
|
-
const c = this.clauses;
|
|
23
|
-
return c.length === 0 ? ''
|
|
24
|
-
: c.length === 1 ? `${c[0]}`
|
|
25
|
-
: `(${c.join(` ${this.op} `)})`;
|
|
26
|
-
}
|
|
27
18
|
}
|
|
28
19
|
export class AndNode extends LogicalOpNode {
|
|
29
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logical-op.js","sourceRoot":"","sources":["../../../src/ast/logical-op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,aAAkC,SAAQ,QAAQ;IAC7D,2BAA2B;IAClB,EAAE,CAAS;IACpB,8BAA8B;IACrB,OAAO,CAAM;IAEtB;;;;OAIG;IACH,YAAY,EAAU,EAAE,OAAY;QAClC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"logical-op.js","sourceRoot":"","sources":["../../../src/ast/logical-op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,aAAkC,SAAQ,QAAQ;IAC7D,2BAA2B;IAClB,EAAE,CAAS;IACpB,8BAA8B;IACrB,OAAO,CAAM;IAEtB;;;;OAIG;IACH,YAAY,EAAU,EAAE,OAAY;QAClC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,OAA4B,SAAQ,aAAgB;IAC/D;;;OAGG;IACH,YAAY,OAAY;QACtB,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxB,CAAC;CACF;AAED,MAAM,OAAO,MAA2B,SAAQ,aAAgB;IAC9D;;;OAGG;IACH,YAAY,OAAY;QACtB,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;CACF"}
|
package/dist/src/ast/node.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { SQLCodeGenerator } from '../visit/codegen/sql.js';
|
|
1
2
|
/**
|
|
2
3
|
* Check if a value is a SQL AST node.
|
|
3
4
|
* @param value The value to check.
|
|
4
5
|
*/
|
|
5
6
|
export declare function isNode(value: unknown): value is SQLNode;
|
|
7
|
+
/**
|
|
8
|
+
* Set the default visitor for toString operations.
|
|
9
|
+
* This is used when no visitor is explicitly provided.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setDefaultVisitor(visitor: SQLCodeGenerator): void;
|
|
6
12
|
export declare class SQLNode {
|
|
7
13
|
/** The SQL AST node type. */
|
|
8
14
|
readonly type: string;
|
|
@@ -16,6 +22,13 @@ export declare class SQLNode {
|
|
|
16
22
|
* @returns The shallow clone node.
|
|
17
23
|
*/
|
|
18
24
|
clone(): this;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a SQL query string for this node using a specific dialect visitor.
|
|
27
|
+
* @param visitor Optional SQL visitor to use for string generation.
|
|
28
|
+
* If not provided, uses the default visitor.
|
|
29
|
+
* @returns The SQL string representation.
|
|
30
|
+
*/
|
|
31
|
+
toString(visitor?: SQLCodeGenerator | undefined): string;
|
|
19
32
|
}
|
|
20
33
|
/**
|
|
21
34
|
* AST node corresponding to an individual expression.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAEvD;AAED,qBAAa,OAAO;IAClB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,KAAK,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAEvD;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,QAE1D;AAED,qBAAa,OAAO;IAClB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,KAAK,IAAI,IAAI;IAWb;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,GAAE,gBAAgB,GAAG,SAA2B,GAAG,MAAM;CAM1E;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,OAAO;CACpC"}
|
package/dist/src/ast/node.js
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
export function isNode(value) {
|
|
6
6
|
return value instanceof SQLNode;
|
|
7
7
|
}
|
|
8
|
+
let _defaultVisitor;
|
|
9
|
+
/**
|
|
10
|
+
* Set the default visitor for toString operations.
|
|
11
|
+
* This is used when no visitor is explicitly provided.
|
|
12
|
+
*/
|
|
13
|
+
export function setDefaultVisitor(visitor) {
|
|
14
|
+
_defaultVisitor = visitor;
|
|
15
|
+
}
|
|
8
16
|
export class SQLNode {
|
|
9
17
|
/** The SQL AST node type. */
|
|
10
18
|
type;
|
|
@@ -20,13 +28,27 @@ export class SQLNode {
|
|
|
20
28
|
* @returns The shallow clone node.
|
|
21
29
|
*/
|
|
22
30
|
clone() {
|
|
23
|
-
// @ts-expect-error use constructor
|
|
24
|
-
const clone = new this.constructor();
|
|
31
|
+
// @ts-expect-error use constructor with type
|
|
32
|
+
const clone = new this.constructor(this.type);
|
|
25
33
|
for (const key in this) {
|
|
26
|
-
|
|
34
|
+
if (key !== 'type') { // Skip type since it's already set by constructor
|
|
35
|
+
clone[key] = this[key];
|
|
36
|
+
}
|
|
27
37
|
}
|
|
28
38
|
return clone;
|
|
29
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Generate a SQL query string for this node using a specific dialect visitor.
|
|
42
|
+
* @param visitor Optional SQL visitor to use for string generation.
|
|
43
|
+
* If not provided, uses the default visitor.
|
|
44
|
+
* @returns The SQL string representation.
|
|
45
|
+
*/
|
|
46
|
+
toString(visitor = _defaultVisitor) {
|
|
47
|
+
if (!visitor) {
|
|
48
|
+
throw new Error('No visitor provided and no default visitor set.');
|
|
49
|
+
}
|
|
50
|
+
return visitor.toString(this);
|
|
51
|
+
}
|
|
30
52
|
}
|
|
31
53
|
/**
|
|
32
54
|
* AST node corresponding to an individual expression.
|
package/dist/src/ast/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/ast/node.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,OAAO,CAAC;AAClC,CAAC;AAED,IAAI,eAA6C,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAyB;IACzD,eAAe,GAAG,OAAO,CAAC;AAC5B,CAAC;AAED,MAAM,OAAO,OAAO;IAClB,6BAA6B;IACpB,IAAI,CAAS;IAEtB;;;OAGG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,6CAA6C;QAC7C,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC,kDAAkD;gBACtE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,UAAwC,eAAe;QAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO;CACpC"}
|
|
@@ -13,9 +13,5 @@ export declare class OrderByNode extends ExprNode {
|
|
|
13
13
|
* @param nullsFirst Flag indicating if null values should be sorted first.
|
|
14
14
|
*/
|
|
15
15
|
constructor(expr: ExprNode, desc?: boolean, nullsFirst?: boolean);
|
|
16
|
-
/**
|
|
17
|
-
* Generate a SQL query string for this node.
|
|
18
|
-
*/
|
|
19
|
-
toString(): string;
|
|
20
16
|
}
|
|
21
17
|
//# sourceMappingURL=order-by.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-by.d.ts","sourceRoot":"","sources":["../../../src/ast/order-by.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,WAAY,SAAQ,QAAQ;IACvC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;OAKG;gBACS,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"order-by.d.ts","sourceRoot":"","sources":["../../../src/ast/order-by.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,WAAY,SAAQ,QAAQ;IACvC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;OAKG;gBACS,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,OAAO;CAMjE"}
|
package/dist/src/ast/order-by.js
CHANGED
|
@@ -19,18 +19,5 @@ export class OrderByNode extends ExprNode {
|
|
|
19
19
|
this.desc = desc;
|
|
20
20
|
this.nullsFirst = nullsFirst;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Generate a SQL query string for this node.
|
|
24
|
-
*/
|
|
25
|
-
toString() {
|
|
26
|
-
const { expr, desc, nullsFirst } = this;
|
|
27
|
-
const dir = desc ? ' DESC'
|
|
28
|
-
: desc === false ? ' ASC'
|
|
29
|
-
: '';
|
|
30
|
-
const nf = nullsFirst ? ' NULLS FIRST'
|
|
31
|
-
: nullsFirst === false ? ' NULLS LAST'
|
|
32
|
-
: '';
|
|
33
|
-
return `${expr}${dir}${nf}`;
|
|
34
|
-
}
|
|
35
22
|
}
|
|
36
23
|
//# sourceMappingURL=order-by.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-by.js","sourceRoot":"","sources":["../../../src/ast/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,kCAAkC;IACzB,IAAI,CAAW;IACxB,wCAAwC;IAC/B,IAAI,CAAW;IACxB,6DAA6D;IACpD,UAAU,CAAW;IAE9B;;;;;OAKG;IACH,YAAY,IAAc,EAAE,IAAc,EAAE,UAAoB;QAC9D,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;
|
|
1
|
+
{"version":3,"file":"order-by.js","sourceRoot":"","sources":["../../../src/ast/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,kCAAkC;IACzB,IAAI,CAAW;IACxB,wCAAwC;IAC/B,IAAI,CAAW;IACxB,6DAA6D;IACpD,UAAU,CAAW;IAE9B;;;;;OAKG;IACH,YAAY,IAAc,EAAE,IAAc,EAAE,UAAoB;QAC9D,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/src/ast/param.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param.d.ts","sourceRoot":"","sources":["../../../src/ast/param.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"param.d.ts","sourceRoot":"","sources":["../../../src/ast/param.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,SAAU,SAAQ,QAAQ;IACrC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAE1B;;;OAGG;gBACS,KAAK,EAAE,SAAS;IAK5B;;OAEG;IACH,IAAI,KAAK,YAER;CACF"}
|
package/dist/src/ast/param.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PARAM } from '../constants.js';
|
|
2
|
-
import { literalToSQL } from './literal.js';
|
|
3
2
|
import { ExprNode } from './node.js';
|
|
4
3
|
export class ParamNode extends ExprNode {
|
|
5
4
|
/** The dynamic parameter. */
|
|
@@ -18,11 +17,5 @@ export class ParamNode extends ExprNode {
|
|
|
18
17
|
get value() {
|
|
19
18
|
return this.param.value;
|
|
20
19
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Generate a SQL query string for this node.
|
|
23
|
-
*/
|
|
24
|
-
toString() {
|
|
25
|
-
return literalToSQL(this.value);
|
|
26
|
-
}
|
|
27
20
|
}
|
|
28
21
|
//# sourceMappingURL=param.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param.js","sourceRoot":"","sources":["../../../src/ast/param.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"param.js","sourceRoot":"","sources":["../../../src/ast/param.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,SAAU,SAAQ,QAAQ;IACrC,6BAA6B;IACpB,KAAK,CAAY;IAE1B;;;OAGG;IACH,YAAY,KAAgB;QAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/src/ast/query.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FilterExpr, FromExpr, GroupByExpr, MaybeArray, OrderByExpr, SelectExpr, WithExpr } from '../types.js';
|
|
2
2
|
import type { SampleMethod } from './sample.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FromNode } from './from.js';
|
|
4
4
|
import { ExprNode, SQLNode } from './node.js';
|
|
5
5
|
import { SampleClauseNode } from './sample.js';
|
|
6
6
|
import { SelectClauseNode } from './select.js';
|
|
@@ -133,7 +133,7 @@ export declare class Query extends ExprNode {
|
|
|
133
133
|
}
|
|
134
134
|
export declare class SelectQuery extends Query {
|
|
135
135
|
_select: SelectClauseNode[];
|
|
136
|
-
_from:
|
|
136
|
+
_from: FromNode[];
|
|
137
137
|
_where: ExprNode[];
|
|
138
138
|
_sample?: SampleClauseNode;
|
|
139
139
|
_groupby: ExprNode[];
|
|
@@ -221,10 +221,6 @@ export declare class SelectQuery extends Query {
|
|
|
221
221
|
* @param expr Expressions to add.
|
|
222
222
|
*/
|
|
223
223
|
qualify(...expr: FilterExpr[]): this;
|
|
224
|
-
/**
|
|
225
|
-
* Generate a SQL query string.
|
|
226
|
-
*/
|
|
227
|
-
toString(): string;
|
|
228
224
|
}
|
|
229
225
|
export declare class DescribeQuery extends SQLNode {
|
|
230
226
|
readonly query: Query;
|
|
@@ -237,10 +233,6 @@ export declare class DescribeQuery extends SQLNode {
|
|
|
237
233
|
* Clone this describe query.
|
|
238
234
|
*/
|
|
239
235
|
clone(): this;
|
|
240
|
-
/**
|
|
241
|
-
* Generate a SQL query string.
|
|
242
|
-
*/
|
|
243
|
-
toString(): string;
|
|
244
236
|
}
|
|
245
237
|
export declare class SetOperation extends Query {
|
|
246
238
|
/** The set operation to perform. */
|
|
@@ -266,10 +258,6 @@ export declare class SetOperation extends Query {
|
|
|
266
258
|
* Clone this set operation.
|
|
267
259
|
*/
|
|
268
260
|
clone(): this;
|
|
269
|
-
/**
|
|
270
|
-
* Generate a SQL query string.
|
|
271
|
-
*/
|
|
272
|
-
toString(): string;
|
|
273
261
|
}
|
|
274
262
|
declare class WithClause {
|
|
275
263
|
/** The common table expressions (CTE). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/ast/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhD,OAAO,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/ast/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhD,OAAO,EAAkB,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,OAAO,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OAGG;IACH,SAAS,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE;CAG9B"}
|
package/dist/src/ast/query.js
CHANGED
|
@@ -4,7 +4,7 @@ import { exprList, nodeList } from '../util/function.js';
|
|
|
4
4
|
import { unquote } from '../util/string.js';
|
|
5
5
|
import { isArray, isString } from '../util/type-check.js';
|
|
6
6
|
import { isColumnRef } from './column-ref.js';
|
|
7
|
-
import { FromClauseNode } from './from.js';
|
|
7
|
+
import { FromClauseNode, FromNode } from './from.js';
|
|
8
8
|
import { ExprNode, SQLNode, isNode } from './node.js';
|
|
9
9
|
import { SampleClauseNode } from './sample.js';
|
|
10
10
|
import { SelectClauseNode } from './select.js';
|
|
@@ -230,15 +230,19 @@ export class SelectQuery extends Query {
|
|
|
230
230
|
const cte = w.reduce((obj, c) => (obj[c.name] = c.query, obj), {});
|
|
231
231
|
// extract subqueries in FROM clause
|
|
232
232
|
// unused CTEs will be ignored
|
|
233
|
+
// WARNING: does not recurse into join inputs!
|
|
233
234
|
const queries = [];
|
|
234
|
-
this._from.forEach(
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
235
|
+
this._from.forEach(node => {
|
|
236
|
+
if (node instanceof FromClauseNode) {
|
|
237
|
+
const { expr } = node;
|
|
238
|
+
if (isQuery(expr)) {
|
|
239
|
+
queries.push(expr);
|
|
240
|
+
}
|
|
241
|
+
else if (isTableRef(expr)) {
|
|
242
|
+
const subq = cte[expr.name];
|
|
243
|
+
if (subq)
|
|
244
|
+
queries.push(subq);
|
|
245
|
+
}
|
|
242
246
|
}
|
|
243
247
|
});
|
|
244
248
|
return queries;
|
|
@@ -308,7 +312,7 @@ export class SelectQuery extends Query {
|
|
|
308
312
|
expr.flat().forEach(e => {
|
|
309
313
|
if (e == null)
|
|
310
314
|
return;
|
|
311
|
-
else if (e instanceof
|
|
315
|
+
else if (e instanceof FromNode)
|
|
312
316
|
list.push(e);
|
|
313
317
|
else if (isString(e))
|
|
314
318
|
add(e, e);
|
|
@@ -416,59 +420,6 @@ export class SelectQuery extends Query {
|
|
|
416
420
|
this._qualify = this._qualify.concat(exprList(expr, asVerbatim));
|
|
417
421
|
return this;
|
|
418
422
|
}
|
|
419
|
-
/**
|
|
420
|
-
* Generate a SQL query string.
|
|
421
|
-
*/
|
|
422
|
-
toString() {
|
|
423
|
-
const { _with, _select, _distinct, _from, _sample, _where, _groupby, _having, _window, _qualify, _orderby, _limitPerc, _limit, _offset } = this;
|
|
424
|
-
const sql = [];
|
|
425
|
-
// WITH
|
|
426
|
-
if (_with.length)
|
|
427
|
-
sql.push(`WITH ${_with.join(', ')}`);
|
|
428
|
-
// SELECT
|
|
429
|
-
sql.push(`SELECT${_distinct ? ' DISTINCT' : ''} ${_select.join(', ')}`);
|
|
430
|
-
// FROM
|
|
431
|
-
if (_from.length)
|
|
432
|
-
sql.push(`FROM ${_from.join(', ')}`);
|
|
433
|
-
// WHERE
|
|
434
|
-
if (_where.length) {
|
|
435
|
-
const clauses = _where.map(String).filter(x => x).join(' AND ');
|
|
436
|
-
if (clauses)
|
|
437
|
-
sql.push(`WHERE ${clauses}`);
|
|
438
|
-
}
|
|
439
|
-
// SAMPLE
|
|
440
|
-
if (_sample)
|
|
441
|
-
sql.push(`USING SAMPLE ${_sample}`);
|
|
442
|
-
// GROUP BY
|
|
443
|
-
if (_groupby.length) {
|
|
444
|
-
sql.push(`GROUP BY ${_groupby.join(', ')}`);
|
|
445
|
-
}
|
|
446
|
-
// HAVING
|
|
447
|
-
if (_having.length) {
|
|
448
|
-
const clauses = _having.map(String).filter(x => x).join(' AND ');
|
|
449
|
-
if (clauses)
|
|
450
|
-
sql.push(`HAVING ${clauses}`);
|
|
451
|
-
}
|
|
452
|
-
// WINDOW
|
|
453
|
-
if (_window.length)
|
|
454
|
-
sql.push(`WINDOW ${_window.join(', ')}`);
|
|
455
|
-
// QUALIFY
|
|
456
|
-
if (_qualify.length) {
|
|
457
|
-
const clauses = _qualify.map(String).filter(x => x).join(' AND ');
|
|
458
|
-
if (clauses)
|
|
459
|
-
sql.push(`QUALIFY ${clauses}`);
|
|
460
|
-
}
|
|
461
|
-
// ORDER BY
|
|
462
|
-
if (_orderby.length)
|
|
463
|
-
sql.push(`ORDER BY ${_orderby.join(', ')}`);
|
|
464
|
-
// LIMIT
|
|
465
|
-
if (_limit)
|
|
466
|
-
sql.push(`LIMIT ${_limit}${_limitPerc ? '%' : ''}`);
|
|
467
|
-
// OFFSET
|
|
468
|
-
if (_offset)
|
|
469
|
-
sql.push(`OFFSET ${_offset}`);
|
|
470
|
-
return sql.join(' ');
|
|
471
|
-
}
|
|
472
423
|
}
|
|
473
424
|
export class DescribeQuery extends SQLNode {
|
|
474
425
|
query;
|
|
@@ -487,12 +438,6 @@ export class DescribeQuery extends SQLNode {
|
|
|
487
438
|
// @ts-expect-error creates describe query
|
|
488
439
|
return new DescribeQuery(this.query.clone());
|
|
489
440
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Generate a SQL query string.
|
|
492
|
-
*/
|
|
493
|
-
toString() {
|
|
494
|
-
return `DESCRIBE ${this.query}`;
|
|
495
|
-
}
|
|
496
441
|
}
|
|
497
442
|
export class SetOperation extends Query {
|
|
498
443
|
/** The set operation to perform. */
|
|
@@ -533,28 +478,6 @@ export class SetOperation extends Query {
|
|
|
533
478
|
// @ts-expect-error creates set operation
|
|
534
479
|
return Object.assign(new SetOperation(op, queries), rest);
|
|
535
480
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Generate a SQL query string.
|
|
538
|
-
*/
|
|
539
|
-
toString() {
|
|
540
|
-
const { op, queries, _with, _orderby, _limitPerc, _limit, _offset } = this;
|
|
541
|
-
const sql = [];
|
|
542
|
-
// WITH
|
|
543
|
-
if (_with.length)
|
|
544
|
-
sql.push(`WITH ${_with.join(', ')}`);
|
|
545
|
-
// SUBQUERIES
|
|
546
|
-
sql.push(queries.join(` ${op} `));
|
|
547
|
-
// ORDER BY
|
|
548
|
-
if (_orderby.length)
|
|
549
|
-
sql.push(`ORDER BY ${_orderby.join(', ')}`);
|
|
550
|
-
// LIMIT
|
|
551
|
-
if (_limit)
|
|
552
|
-
sql.push(`LIMIT ${_limit}${_limitPerc ? '%' : ''}`);
|
|
553
|
-
// OFFSET
|
|
554
|
-
if (_offset)
|
|
555
|
-
sql.push(`OFFSET ${_offset}`);
|
|
556
|
-
return sql.join(' ');
|
|
557
|
-
}
|
|
558
481
|
}
|
|
559
482
|
class WithClause {
|
|
560
483
|
/** The common table expressions (CTE). */
|