@uwdata/mosaic-sql 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +47 -0
- package/README.md +0 -2
- package/dist/src/ast/aggregate.d.ts +82 -0
- package/dist/src/ast/aggregate.d.ts.map +1 -0
- package/dist/src/ast/aggregate.js +180 -0
- package/dist/src/ast/aggregate.js.map +1 -0
- package/dist/src/ast/between-op.d.ts +46 -0
- package/dist/src/ast/between-op.d.ts.map +1 -0
- package/dist/src/ast/between-op.js +60 -0
- package/dist/src/ast/between-op.js.map +1 -0
- package/dist/src/ast/binary-op.d.ts +21 -0
- package/dist/src/ast/binary-op.d.ts.map +1 -0
- package/dist/src/ast/binary-op.js +29 -0
- package/dist/src/ast/binary-op.js.map +1 -0
- package/dist/src/ast/case.d.ts +53 -0
- package/dist/src/ast/case.d.ts.map +1 -0
- package/dist/src/ast/case.js +75 -0
- package/dist/src/ast/case.js.map +1 -0
- package/dist/src/ast/cast.d.ts +18 -0
- package/dist/src/ast/cast.d.ts.map +1 -0
- package/dist/src/ast/cast.js +26 -0
- package/dist/src/ast/cast.js.map +1 -0
- package/dist/src/ast/collate.d.ts +18 -0
- package/dist/src/ast/collate.d.ts.map +1 -0
- package/dist/src/ast/collate.js +25 -0
- package/dist/src/ast/collate.js.map +1 -0
- package/dist/src/ast/column-param.d.ts +23 -0
- package/dist/src/ast/column-param.d.ts.map +1 -0
- package/dist/src/ast/column-param.js +29 -0
- package/dist/src/ast/column-param.js.map +1 -0
- package/dist/src/ast/column-ref.d.ts +40 -0
- package/dist/src/ast/column-ref.d.ts.map +1 -0
- package/dist/src/ast/column-ref.js +58 -0
- package/dist/src/ast/column-ref.js.map +1 -0
- package/dist/src/ast/fragment.d.ts +20 -0
- package/dist/src/ast/fragment.d.ts.map +1 -0
- package/dist/src/ast/fragment.js +26 -0
- package/dist/src/ast/fragment.js.map +1 -0
- package/dist/src/ast/from.d.ts +22 -0
- package/dist/src/ast/from.d.ts.map +1 -0
- package/dist/src/ast/from.js +37 -0
- package/dist/src/ast/from.js.map +1 -0
- package/dist/src/ast/function.d.ts +18 -0
- package/dist/src/ast/function.d.ts.map +1 -0
- package/dist/src/ast/function.js +26 -0
- package/dist/src/ast/function.js.map +1 -0
- package/dist/src/ast/in-op.d.ts +18 -0
- package/dist/src/ast/in-op.d.ts.map +1 -0
- package/dist/src/ast/in-op.js +25 -0
- package/dist/src/ast/in-op.js.map +1 -0
- package/dist/src/ast/interval.d.ts +18 -0
- package/dist/src/ast/interval.d.ts.map +1 -0
- package/dist/src/ast/interval.js +25 -0
- package/dist/src/ast/interval.js.map +1 -0
- package/dist/src/ast/list.d.ts +15 -0
- package/dist/src/ast/list.d.ts.map +1 -0
- package/dist/src/ast/list.js +21 -0
- package/dist/src/ast/list.js.map +1 -0
- package/dist/src/ast/literal.d.ts +16 -0
- package/dist/src/ast/literal.d.ts.map +1 -0
- package/dist/src/ast/literal.js +53 -0
- package/dist/src/ast/literal.js.map +1 -0
- package/dist/src/ast/logical-op.d.ts +32 -0
- package/dist/src/ast/logical-op.d.ts.map +1 -0
- package/dist/src/ast/logical-op.js +46 -0
- package/dist/src/ast/logical-op.js.map +1 -0
- package/dist/src/ast/node.d.ts +25 -0
- package/dist/src/ast/node.d.ts.map +1 -0
- package/dist/src/ast/node.js +36 -0
- package/dist/src/ast/node.js.map +1 -0
- package/dist/src/ast/order-by.d.ts +21 -0
- package/dist/src/ast/order-by.d.ts.map +1 -0
- package/dist/src/ast/order-by.js +36 -0
- package/dist/src/ast/order-by.js.map +1 -0
- package/dist/src/ast/param.d.ts +20 -0
- package/dist/src/ast/param.d.ts.map +1 -0
- package/dist/src/ast/param.js +28 -0
- package/dist/src/ast/param.js.map +1 -0
- package/dist/src/ast/query.d.ts +334 -0
- package/dist/src/ast/query.d.ts.map +1 -0
- package/dist/src/ast/query.js +640 -0
- package/dist/src/ast/query.js.map +1 -0
- package/dist/src/ast/sample.d.ts +27 -0
- package/dist/src/ast/sample.d.ts.map +1 -0
- package/dist/src/ast/sample.js +38 -0
- package/dist/src/ast/sample.js.map +1 -0
- package/dist/src/ast/select.d.ts +19 -0
- package/dist/src/ast/select.d.ts.map +1 -0
- package/dist/src/ast/select.js +35 -0
- package/dist/src/ast/select.js.map +1 -0
- package/dist/src/ast/subquery.d.ts +16 -0
- package/dist/src/ast/subquery.d.ts.map +1 -0
- package/dist/src/ast/subquery.js +21 -0
- package/dist/src/ast/subquery.js.map +1 -0
- package/dist/src/ast/table-ref.d.ts +24 -0
- package/dist/src/ast/table-ref.d.ts.map +1 -0
- package/dist/src/ast/table-ref.js +35 -0
- package/dist/src/ast/table-ref.js.map +1 -0
- package/dist/src/ast/unary-op.d.ts +40 -0
- package/dist/src/ast/unary-op.d.ts.map +1 -0
- package/dist/src/ast/unary-op.js +52 -0
- package/dist/src/ast/unary-op.js.map +1 -0
- package/dist/src/ast/unnest.d.ts +19 -0
- package/dist/src/ast/unnest.d.ts.map +1 -0
- package/dist/src/ast/unnest.js +29 -0
- package/dist/src/ast/unnest.js.map +1 -0
- package/dist/src/ast/verbatim.d.ts +18 -0
- package/dist/src/ast/verbatim.d.ts.map +1 -0
- package/dist/src/ast/verbatim.js +25 -0
- package/dist/src/ast/verbatim.js.map +1 -0
- package/dist/src/ast/window-frame.d.ts +54 -0
- package/dist/src/ast/window-frame.d.ts.map +1 -0
- package/dist/src/ast/window-frame.js +79 -0
- package/dist/src/ast/window-frame.js.map +1 -0
- package/dist/src/ast/window.d.ts +128 -0
- package/dist/src/ast/window.d.ts.map +1 -0
- package/dist/src/ast/window.js +194 -0
- package/dist/src/ast/window.js.map +1 -0
- package/dist/src/ast/with.d.ts +25 -0
- package/dist/src/ast/with.d.ts.map +1 -0
- package/dist/src/ast/with.js +36 -0
- package/dist/src/ast/with.js.map +1 -0
- package/dist/src/constants.d.ts +40 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +40 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/functions/aggregate.d.ts +236 -0
- package/dist/src/functions/aggregate.d.ts.map +1 -0
- package/dist/src/functions/aggregate.js +308 -0
- package/dist/src/functions/aggregate.js.map +1 -0
- package/dist/src/functions/case.d.ts +13 -0
- package/dist/src/functions/case.d.ts.map +1 -0
- package/dist/src/functions/case.js +17 -0
- package/dist/src/functions/case.js.map +1 -0
- package/dist/src/functions/cast.d.ts +23 -0
- package/dist/src/functions/cast.d.ts.map +1 -0
- package/dist/src/functions/cast.js +32 -0
- package/dist/src/functions/cast.js.map +1 -0
- package/dist/src/functions/collate.d.ts +10 -0
- package/dist/src/functions/collate.d.ts.map +1 -0
- package/dist/src/functions/collate.js +12 -0
- package/dist/src/functions/collate.js.map +1 -0
- package/dist/src/functions/column.d.ts +10 -0
- package/dist/src/functions/column.d.ts.map +1 -0
- package/dist/src/functions/column.js +17 -0
- package/dist/src/functions/column.js.map +1 -0
- package/dist/src/functions/cte.d.ts +13 -0
- package/dist/src/functions/cte.d.ts.map +1 -0
- package/dist/src/functions/cte.js +14 -0
- package/dist/src/functions/cte.js.map +1 -0
- package/dist/src/functions/datetime.d.ts +32 -0
- package/dist/src/functions/datetime.d.ts.map +1 -0
- package/dist/src/functions/datetime.js +45 -0
- package/dist/src/functions/datetime.js.map +1 -0
- package/dist/src/functions/interval.d.ts +48 -0
- package/dist/src/functions/interval.d.ts.map +1 -0
- package/dist/src/functions/interval.js +66 -0
- package/dist/src/functions/interval.js.map +1 -0
- package/dist/src/functions/list.d.ts +31 -0
- package/dist/src/functions/list.d.ts.map +1 -0
- package/dist/src/functions/list.js +49 -0
- package/dist/src/functions/list.js.map +1 -0
- package/dist/src/functions/literal.d.ts +16 -0
- package/dist/src/functions/literal.d.ts.map +1 -0
- package/dist/src/functions/literal.js +20 -0
- package/dist/src/functions/literal.js.map +1 -0
- package/dist/src/functions/numeric.d.ts +80 -0
- package/dist/src/functions/numeric.d.ts.map +1 -0
- package/dist/src/functions/numeric.js +110 -0
- package/dist/src/functions/numeric.js.map +1 -0
- package/dist/src/functions/operators.d.ts +169 -0
- package/dist/src/functions/operators.d.ts.map +1 -0
- package/dist/src/functions/operators.js +235 -0
- package/dist/src/functions/operators.js.map +1 -0
- package/dist/src/functions/order-by.d.ts +15 -0
- package/dist/src/functions/order-by.d.ts.map +1 -0
- package/dist/src/functions/order-by.js +19 -0
- package/dist/src/functions/order-by.js.map +1 -0
- package/dist/src/functions/spatial.d.ts +32 -0
- package/dist/src/functions/spatial.d.ts.map +1 -0
- package/dist/src/functions/spatial.js +44 -0
- package/dist/src/functions/spatial.js.map +1 -0
- package/dist/src/functions/sql-template-tag.d.ts +13 -0
- package/dist/src/functions/sql-template-tag.d.ts.map +1 -0
- package/dist/src/functions/sql-template-tag.js +44 -0
- package/dist/src/functions/sql-template-tag.js.map +1 -0
- package/dist/src/functions/string.d.ts +49 -0
- package/dist/src/functions/string.d.ts.map +1 -0
- package/dist/src/functions/string.js +67 -0
- package/dist/src/functions/string.js.map +1 -0
- package/dist/src/functions/table-ref.d.ts +10 -0
- package/dist/src/functions/table-ref.d.ts.map +1 -0
- package/dist/src/functions/table-ref.js +13 -0
- package/dist/src/functions/table-ref.js.map +1 -0
- package/dist/src/functions/unnest.d.ts +10 -0
- package/dist/src/functions/unnest.d.ts.map +1 -0
- package/dist/src/functions/unnest.js +12 -0
- package/dist/src/functions/unnest.js.map +1 -0
- package/dist/src/functions/util.d.ts +7 -0
- package/dist/src/functions/util.d.ts.map +1 -0
- package/dist/src/functions/util.js +9 -0
- package/dist/src/functions/util.js.map +1 -0
- package/dist/src/functions/window-frame.d.ts +41 -0
- package/dist/src/functions/window-frame.d.ts.map +1 -0
- package/dist/src/functions/window-frame.js +52 -0
- package/dist/src/functions/window-frame.js.map +1 -0
- package/dist/src/functions/window.d.ts +74 -0
- package/dist/src/functions/window.d.ts.map +1 -0
- package/dist/src/functions/window.js +96 -0
- package/dist/src/functions/window.js.map +1 -0
- package/dist/src/index.d.ts +73 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{src → dist/src}/index.js +8 -8
- package/dist/src/index.js.map +1 -0
- package/dist/src/load/create.d.ts +10 -0
- package/dist/src/load/create.d.ts.map +1 -0
- package/dist/src/load/create.js +14 -0
- package/dist/src/load/create.js.map +1 -0
- package/dist/src/load/extension.d.ts +2 -0
- package/dist/src/load/extension.d.ts.map +1 -0
- package/dist/src/load/extension.js +4 -0
- package/dist/src/load/extension.js.map +1 -0
- package/dist/src/load/load.d.ts +18 -0
- package/dist/src/load/load.d.ts.map +1 -0
- package/dist/src/load/load.js +80 -0
- package/dist/src/load/load.js.map +1 -0
- package/dist/src/load/sql-from.d.ts +14 -0
- package/dist/src/load/sql-from.d.ts.map +1 -0
- package/dist/src/load/sql-from.js +29 -0
- package/dist/src/load/sql-from.js.map +1 -0
- package/dist/src/transforms/bin-1d.d.ts +16 -0
- package/dist/src/transforms/bin-1d.d.ts.map +1 -0
- package/dist/src/transforms/bin-1d.js +21 -0
- package/dist/src/transforms/bin-1d.js.map +1 -0
- package/dist/src/transforms/bin-2d.d.ts +19 -0
- package/dist/src/transforms/bin-2d.d.ts.map +1 -0
- package/dist/src/transforms/bin-2d.js +27 -0
- package/dist/src/transforms/bin-2d.js.map +1 -0
- package/dist/src/transforms/bin-date.d.ts +31 -0
- package/dist/src/transforms/bin-date.d.ts.map +1 -0
- package/dist/src/transforms/bin-date.js +20 -0
- package/dist/src/transforms/bin-date.js.map +1 -0
- package/dist/src/transforms/bin-histogram.d.ts +37 -0
- package/dist/src/transforms/bin-histogram.d.ts.map +1 -0
- package/dist/src/transforms/bin-histogram.js +32 -0
- package/dist/src/transforms/bin-histogram.js.map +1 -0
- package/dist/src/transforms/bin-linear-1d.d.ts +11 -0
- package/dist/src/transforms/bin-linear-1d.d.ts.map +1 -0
- package/dist/src/transforms/bin-linear-1d.js +25 -0
- package/dist/src/transforms/bin-linear-1d.js.map +1 -0
- package/dist/src/transforms/bin-linear-2d.d.ts +20 -0
- package/dist/src/transforms/bin-linear-2d.d.ts.map +1 -0
- package/dist/src/transforms/bin-linear-2d.js +49 -0
- package/dist/src/transforms/bin-linear-2d.js.map +1 -0
- package/dist/src/transforms/filter-query.d.ts +12 -0
- package/dist/src/transforms/filter-query.d.ts.map +1 -0
- package/dist/src/transforms/filter-query.js +39 -0
- package/dist/src/transforms/filter-query.js.map +1 -0
- package/dist/src/transforms/line-density.d.ts +24 -0
- package/dist/src/transforms/line-density.d.ts.map +1 -0
- package/dist/src/transforms/line-density.js +98 -0
- package/dist/src/transforms/line-density.js.map +1 -0
- package/dist/src/transforms/m4.d.ts +19 -0
- package/dist/src/transforms/m4.d.ts.map +1 -0
- package/dist/src/transforms/m4.js +38 -0
- package/dist/src/transforms/m4.js.map +1 -0
- package/dist/src/transforms/scales.d.ts +30 -0
- package/dist/src/transforms/scales.d.ts.map +1 -0
- package/dist/src/transforms/scales.js +103 -0
- package/dist/src/transforms/scales.js.map +1 -0
- package/dist/src/transforms/util/bin-step.d.ts +50 -0
- package/dist/src/transforms/util/bin-step.d.ts.map +1 -0
- package/dist/src/transforms/util/bin-step.js +53 -0
- package/dist/src/transforms/util/bin-step.js.map +1 -0
- package/dist/src/transforms/util/time-interval.d.ts +14 -0
- package/dist/src/transforms/util/time-interval.d.ts.map +1 -0
- package/dist/src/transforms/util/time-interval.js +88 -0
- package/dist/src/transforms/util/time-interval.js.map +1 -0
- package/dist/src/types.d.ts +49 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/util/ast.d.ts +62 -0
- package/dist/src/util/ast.d.ts.map +1 -0
- package/{src → dist/src}/util/ast.js +36 -41
- package/dist/src/util/ast.js.map +1 -0
- package/dist/src/util/function.d.ts +56 -0
- package/dist/src/util/function.d.ts.map +1 -0
- package/dist/src/util/function.js +73 -0
- package/dist/src/util/function.js.map +1 -0
- package/dist/src/util/identity.d.ts +6 -0
- package/dist/src/util/identity.d.ts.map +1 -0
- package/dist/src/util/identity.js +8 -0
- package/dist/src/util/identity.js.map +1 -0
- package/dist/src/util/string.d.ts +4 -0
- package/dist/src/util/string.d.ts.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/type-check.d.ts +17 -0
- package/dist/src/util/type-check.d.ts.map +1 -0
- package/dist/src/util/type-check.js +28 -0
- package/dist/src/util/type-check.js.map +1 -0
- package/dist/src/visit/clone.d.ts +7 -0
- package/dist/src/visit/clone.d.ts.map +1 -0
- package/dist/src/visit/clone.js +52 -0
- package/dist/src/visit/clone.js.map +1 -0
- package/dist/src/visit/recurse.d.ts +2 -0
- package/dist/src/visit/recurse.d.ts.map +1 -0
- package/dist/src/visit/recurse.js +37 -0
- package/dist/src/visit/recurse.js.map +1 -0
- package/dist/src/visit/rewrite.d.ts +9 -0
- package/dist/src/visit/rewrite.d.ts.map +1 -0
- package/dist/src/visit/rewrite.js +39 -0
- package/dist/src/visit/rewrite.js.map +1 -0
- package/dist/src/visit/visitors.d.ts +32 -0
- package/dist/src/visit/visitors.d.ts.map +1 -0
- package/dist/src/visit/visitors.js +95 -0
- package/dist/src/visit/visitors.js.map +1 -0
- package/dist/src/visit/walk.d.ts +21 -0
- package/dist/src/visit/walk.d.ts.map +1 -0
- package/dist/src/visit/walk.js +32 -0
- package/dist/src/visit/walk.js.map +1 -0
- package/package.json +13 -7
- package/src/ast/{aggregate.js → aggregate.ts} +49 -60
- package/src/ast/{between-op.js → between-op.ts} +19 -26
- package/src/ast/binary-op.ts +31 -0
- package/src/ast/{case.js → case.ts} +29 -44
- package/src/ast/{cast.js → cast.ts} +8 -14
- package/src/ast/{collate.js → collate.ts} +8 -14
- package/src/ast/column-param.ts +34 -0
- package/src/ast/{column-ref.js → column-ref.ts} +16 -25
- package/src/ast/fragment.ts +28 -0
- package/src/ast/{from.js → from.ts} +12 -21
- package/src/ast/{function.js → function.ts} +8 -14
- package/src/ast/{in-op.js → in-op.ts} +8 -14
- package/src/ast/{interval.js → interval.ts} +8 -14
- package/src/ast/list.ts +23 -0
- package/src/ast/{literal.js → literal.ts} +6 -9
- package/src/ast/logical-op.ts +50 -0
- package/src/ast/{node.js → node.ts} +10 -13
- package/src/ast/order-by.ts +38 -0
- package/src/ast/{param.js → param.ts} +6 -12
- package/src/ast/{query.js → query.ts} +224 -204
- package/src/ast/sample.ts +47 -0
- package/src/ast/{select.js → select.ts} +10 -16
- package/src/ast/{subquery.js → subquery.ts} +9 -8
- package/src/ast/{table-ref.js → table-ref.ts} +7 -12
- package/src/ast/{unary-op.js → unary-op.ts} +16 -23
- package/src/ast/unnest.ts +31 -0
- package/src/ast/verbatim.ts +27 -0
- package/src/ast/{window-frame.js → window-frame.ts} +37 -47
- package/src/ast/window.ts +246 -0
- package/src/ast/{with.js → with.ts} +19 -20
- package/src/{constants.js → constants.ts} +2 -0
- package/src/functions/aggregate.ts +344 -0
- package/src/functions/{case.js → case.ts} +5 -8
- package/src/functions/{cast.js → cast.ts} +9 -13
- package/src/functions/{collate.js → collate.ts} +4 -7
- package/src/functions/{column.js → column.ts} +9 -10
- package/src/functions/{cte.js → cte.ts} +9 -6
- package/src/functions/{datetime.js → datetime.ts} +12 -20
- package/src/functions/interval.ts +74 -0
- package/src/functions/list.ts +63 -0
- package/src/functions/{literal.js → literal.ts} +5 -7
- package/src/functions/numeric.ts +125 -0
- package/src/functions/operators.ts +272 -0
- package/src/functions/order-by.ts +21 -0
- package/src/functions/spatial.ts +50 -0
- package/src/functions/{sql-template-tag.js → sql-template-tag.ts} +16 -13
- package/src/functions/string.ts +79 -0
- package/src/functions/{table-ref.js → table-ref.ts} +4 -4
- package/src/functions/unnest.ts +13 -0
- package/src/functions/util.ts +10 -0
- package/src/functions/window-frame.ts +58 -0
- package/src/functions/{window.js → window.ts} +18 -35
- package/src/index.ts +79 -0
- package/src/load/{create.js → create.ts} +9 -3
- package/src/load/extension.ts +3 -0
- package/src/load/{load.js → load.ts} +25 -10
- package/src/load/{sql-from.js → sql-from.ts} +14 -7
- package/src/transforms/{bin-1d.js → bin-1d.ts} +13 -9
- package/src/transforms/{bin-2d.js → bin-2d.ts} +17 -13
- package/src/transforms/bin-date.ts +48 -0
- package/src/transforms/bin-histogram.ts +61 -0
- package/src/transforms/{bin-linear-1d.js → bin-linear-1d.ts} +16 -11
- package/src/transforms/{bin-linear-2d.js → bin-linear-2d.ts} +23 -35
- package/src/transforms/{filter-query.js → filter-query.ts} +10 -14
- package/src/transforms/{line-density.js → line-density.ts} +19 -17
- package/src/transforms/{m4.js → m4.ts} +17 -14
- package/src/transforms/{scales.js → scales.ts} +57 -14
- package/src/transforms/util/bin-step.ts +100 -0
- package/src/transforms/util/{time-interval.js → time-interval.ts} +32 -21
- package/src/types.ts +5 -39
- package/src/util/ast.ts +104 -0
- package/src/util/{function.js → function.ts} +40 -31
- package/src/util/identity.ts +7 -0
- package/src/util/{string.js → string.ts} +4 -4
- package/src/util/type-check.ts +31 -0
- package/src/visit/{clone.js → clone.ts} +10 -10
- package/src/visit/{recurse.js → recurse.ts} +3 -1
- package/src/visit/{rewrite.js → rewrite.ts} +7 -7
- package/src/visit/{visitors.js → visitors.ts} +22 -30
- package/src/visit/walk.ts +46 -0
- package/src/ast/binary-op.js +0 -40
- package/src/ast/column-param.js +0 -40
- package/src/ast/fragment.js +0 -26
- package/src/ast/logical-op.js +0 -67
- package/src/ast/order-by.js +0 -48
- package/src/ast/sample.js +0 -53
- package/src/ast/verbatim.js +0 -33
- package/src/ast/window.js +0 -260
- package/src/functions/aggregate.js +0 -347
- package/src/functions/interval.js +0 -83
- package/src/functions/numeric.js +0 -143
- package/src/functions/operators.js +0 -301
- package/src/functions/order-by.js +0 -27
- package/src/functions/spatial.js +0 -59
- package/src/functions/string.js +0 -85
- package/src/functions/util.js +0 -14
- package/src/functions/window-frame.js +0 -61
- package/src/index-types.ts +0 -2
- package/src/load/extension.js +0 -3
- package/src/transforms/bin-date.js +0 -38
- package/src/transforms/bin-histogram.js +0 -52
- package/src/transforms/util/bin-step.js +0 -79
- package/src/util/type-check.js +0 -33
- package/src/visit/walk.js +0 -34
- package/tsconfig.json +0 -8
- package/vitest.config.ts +0 -3
|
@@ -1,50 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
* @import { ExprValue } from '../types.js'
|
|
3
|
-
*/
|
|
1
|
+
import { ExprValue } from '../types.js';
|
|
4
2
|
import { CASE, WHEN } from '../constants.js';
|
|
5
3
|
import { asNode } from '../util/ast.js';
|
|
6
4
|
import { ExprNode, SQLNode } from './node.js';
|
|
7
5
|
|
|
8
6
|
export class CaseNode extends ExprNode {
|
|
7
|
+
/** The optional base expression. */
|
|
8
|
+
readonly expr?: ExprNode;
|
|
9
|
+
/** An array of WHEN/THEN expression nodes. */
|
|
10
|
+
readonly _when: WhenNode[];
|
|
11
|
+
/** An ELSE expression. */
|
|
12
|
+
readonly _else?: ExprNode;
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Instantiate a case node.
|
|
11
|
-
* @param
|
|
16
|
+
* @param expr An optional base expression, that comes
|
|
12
17
|
* immediately after the CASE keyword. If specified, this case statement
|
|
13
18
|
* acts like a switch statement, with WHEN expressions as values to
|
|
14
19
|
* match against the switch value rather than boolean conditions.
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
20
|
+
* @param when An array of WHEN/THEN expression nodes.
|
|
21
|
+
* @param elseExpr An ELSE expression.
|
|
17
22
|
*/
|
|
18
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
expr: ExprNode | undefined = undefined,
|
|
25
|
+
when: WhenNode[] = [],
|
|
26
|
+
elseExpr: ExprNode | undefined = undefined
|
|
27
|
+
) {
|
|
19
28
|
super(CASE);
|
|
20
|
-
/**
|
|
21
|
-
* The optional base expression.
|
|
22
|
-
* @type {ExprNode}
|
|
23
|
-
* @readonly
|
|
24
|
-
*/
|
|
25
29
|
this.expr = expr;
|
|
26
|
-
/**
|
|
27
|
-
* An array of WHEN/THEN expression nodes.
|
|
28
|
-
* @type {WhenNode[]}
|
|
29
|
-
* @readonly
|
|
30
|
-
*/
|
|
31
30
|
this._when = when;
|
|
32
|
-
/**
|
|
33
|
-
* An ELSE expression.
|
|
34
|
-
* @type {ExprNode}
|
|
35
|
-
* @readonly
|
|
36
|
-
*/
|
|
37
31
|
this._else = elseExpr;
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
/**
|
|
41
35
|
* Return a new case node with the given conditional added as
|
|
42
36
|
* the last WHEN / THEN pair.
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {CaseNode}
|
|
37
|
+
* @param cond The WHEN condition expression.
|
|
38
|
+
* @param value The THEN value expression.
|
|
46
39
|
*/
|
|
47
|
-
when(cond, value) {
|
|
40
|
+
when(cond: ExprValue, value: ExprValue) {
|
|
48
41
|
return new CaseNode(
|
|
49
42
|
this.expr,
|
|
50
43
|
this._when.concat(new WhenNode(asNode(cond), asNode(value))),
|
|
@@ -54,16 +47,14 @@ export class CaseNode extends ExprNode {
|
|
|
54
47
|
|
|
55
48
|
/**
|
|
56
49
|
* Return a new case node with the given ELSE expression.
|
|
57
|
-
* @param
|
|
58
|
-
* @returns {CaseNode}
|
|
50
|
+
* @param expr The ELSE expression.
|
|
59
51
|
*/
|
|
60
|
-
else(expr) {
|
|
52
|
+
else(expr: ExprValue) {
|
|
61
53
|
return new CaseNode(this.expr, this._when, asNode(expr));
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
/**
|
|
65
57
|
* Generate a SQL query string for this node.
|
|
66
|
-
* @returns {string}
|
|
67
58
|
*/
|
|
68
59
|
toString() {
|
|
69
60
|
return 'CASE '
|
|
@@ -75,30 +66,24 @@ export class CaseNode extends ExprNode {
|
|
|
75
66
|
}
|
|
76
67
|
|
|
77
68
|
export class WhenNode extends SQLNode {
|
|
69
|
+
/** The condition expression. */
|
|
70
|
+
readonly when: ExprNode;
|
|
71
|
+
/** The value expression. */
|
|
72
|
+
readonly then: ExprNode;
|
|
73
|
+
|
|
78
74
|
/**
|
|
79
75
|
* Instantiate a case node.
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
76
|
+
* @param when The WHEN condition expression.
|
|
77
|
+
* @param then The THEN value expression.
|
|
82
78
|
*/
|
|
83
|
-
constructor(when, then) {
|
|
79
|
+
constructor(when: ExprNode, then: ExprNode) {
|
|
84
80
|
super(WHEN);
|
|
85
|
-
/**
|
|
86
|
-
* The condition expression.
|
|
87
|
-
* @type {ExprNode}
|
|
88
|
-
* @readonly
|
|
89
|
-
*/
|
|
90
81
|
this.when = when;
|
|
91
|
-
/**
|
|
92
|
-
* The value expression.
|
|
93
|
-
* @type {ExprNode}
|
|
94
|
-
* @readonly
|
|
95
|
-
*/
|
|
96
82
|
this.then = then;
|
|
97
83
|
}
|
|
98
84
|
|
|
99
85
|
/**
|
|
100
86
|
* Generate a SQL query string for this node.
|
|
101
|
-
* @returns {string}
|
|
102
87
|
*/
|
|
103
88
|
toString() {
|
|
104
89
|
return `WHEN ${this.when} THEN ${this.then}`;
|
|
@@ -2,30 +2,24 @@ import { CAST } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class CastNode extends ExprNode {
|
|
5
|
+
/** The expression to type cast. */
|
|
6
|
+
readonly expr: ExprNode;
|
|
7
|
+
/** The type to cast to. */
|
|
8
|
+
readonly cast: string;
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Instantiate a cast node.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
12
|
+
* @param expr The expression to type cast.
|
|
13
|
+
* @param type The type to cast to.
|
|
9
14
|
*/
|
|
10
|
-
constructor(expr, type) {
|
|
15
|
+
constructor(expr: ExprNode, type: string) {
|
|
11
16
|
super(CAST);
|
|
12
|
-
/**
|
|
13
|
-
* The expression to type cast.
|
|
14
|
-
* @type {ExprNode}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
17
|
this.expr = expr;
|
|
18
|
-
/**
|
|
19
|
-
* The type to cast to.
|
|
20
|
-
* @type {string}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
18
|
this.cast = type;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
27
22
|
* Generate a SQL query string for this node.
|
|
28
|
-
* @returns {string}
|
|
29
23
|
*/
|
|
30
24
|
toString() {
|
|
31
25
|
// TODO? could include check to see if parens are necessary
|
|
@@ -2,30 +2,24 @@ import { COLLATE } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class CollateNode extends ExprNode {
|
|
5
|
+
/** The expression to collate. */
|
|
6
|
+
readonly expr: ExprNode;
|
|
7
|
+
/** The collation type. */
|
|
8
|
+
readonly collation: string;
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Instantiate a collate node.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
12
|
+
* @param expr The expression to collate.
|
|
13
|
+
* @param collation The collation type.
|
|
9
14
|
*/
|
|
10
|
-
constructor(expr, collation) {
|
|
15
|
+
constructor(expr: ExprNode, collation: string) {
|
|
11
16
|
super(COLLATE);
|
|
12
|
-
/**
|
|
13
|
-
* The expression to collate.
|
|
14
|
-
* @type {ExprNode}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
17
|
this.expr = expr;
|
|
18
|
-
/**
|
|
19
|
-
* The collation type.
|
|
20
|
-
* @type {string}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
18
|
this.collation = collation;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
27
22
|
* Generate a SQL query string for this node.
|
|
28
|
-
* @returns {string}
|
|
29
23
|
*/
|
|
30
24
|
toString() {
|
|
31
25
|
return `${this.expr} ${COLLATE} ${this.collation}`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ParamNode } from './param.js';
|
|
2
|
+
import type { TableRefNode } from './table-ref.js';
|
|
3
|
+
import { COLUMN_PARAM } from '../constants.js';
|
|
4
|
+
import { ColumnRefNode } from './column-ref.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check if a value is a dynamic column reference node.
|
|
8
|
+
* @param value The value to check.
|
|
9
|
+
*/
|
|
10
|
+
export function isColumnParam(value: unknown): value is ColumnParamNode {
|
|
11
|
+
return value instanceof ColumnParamNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ColumnParamNode extends ColumnRefNode {
|
|
15
|
+
/** The column name as a parameter node */
|
|
16
|
+
readonly param: ParamNode;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Instantiate a column param node.
|
|
20
|
+
* @param param The column name as a parameter node.
|
|
21
|
+
* @param table The table reference.
|
|
22
|
+
*/
|
|
23
|
+
constructor(param: ParamNode, table?: TableRefNode) {
|
|
24
|
+
super(COLUMN_PARAM, table);
|
|
25
|
+
this.param = param;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the column name.
|
|
30
|
+
*/
|
|
31
|
+
get column() {
|
|
32
|
+
return `${this.param.value}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
* @import { TableRefNode } from './table-ref.js'
|
|
3
|
-
*/
|
|
1
|
+
import type { TableRefNode } from './table-ref.js';
|
|
4
2
|
import { COLUMN_REF } from '../constants.js';
|
|
5
3
|
import { quoteIdentifier } from '../util/string.js';
|
|
6
4
|
import { ExprNode } from './node.js';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Check if a value is a column reference node.
|
|
10
|
-
* @param
|
|
11
|
-
* @returns {value is ColumnRefNode}
|
|
8
|
+
* @param value The value to check.
|
|
12
9
|
*/
|
|
13
|
-
export function isColumnRef(value) {
|
|
10
|
+
export function isColumnRef(value: unknown): value is ColumnRefNode {
|
|
14
11
|
return value instanceof ColumnRefNode;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
export class ColumnRefNode extends ExprNode {
|
|
15
|
+
/** The table reference. */
|
|
16
|
+
readonly table?: TableRefNode;
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* Instantiate a column reference node.
|
|
20
|
-
* @param
|
|
20
|
+
* @param type The AST node type.
|
|
21
|
+
* @param table The table reference.
|
|
21
22
|
*/
|
|
22
|
-
constructor(type, table) {
|
|
23
|
+
constructor(type: string, table?: TableRefNode) {
|
|
23
24
|
super(type);
|
|
24
|
-
/**
|
|
25
|
-
* The table reference.
|
|
26
|
-
* @type {TableRefNode}
|
|
27
|
-
* @readonly
|
|
28
|
-
*/
|
|
29
25
|
this.table = table;
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
29
|
* Returns the column name.
|
|
34
|
-
* @returns {string}
|
|
35
30
|
*/
|
|
36
31
|
get column() {
|
|
37
|
-
return
|
|
32
|
+
return ''; // subclasses to override
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
/**
|
|
41
36
|
* Generate a SQL query string for this node.
|
|
42
|
-
* @returns {string}
|
|
43
37
|
*/
|
|
44
38
|
toString() {
|
|
45
39
|
const { column, table } = this;
|
|
@@ -50,24 +44,21 @@ export class ColumnRefNode extends ExprNode {
|
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
export class ColumnNameRefNode extends ColumnRefNode {
|
|
47
|
+
/** The column name. */
|
|
48
|
+
readonly name: string;
|
|
49
|
+
|
|
53
50
|
/**
|
|
54
51
|
* Instantiate a column reference node.
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
52
|
+
* @param name The column name.
|
|
53
|
+
* @param table The table reference.
|
|
57
54
|
*/
|
|
58
|
-
constructor(name, table) {
|
|
55
|
+
constructor(name: string, table?: TableRefNode) {
|
|
59
56
|
super(COLUMN_REF, table);
|
|
60
|
-
/**
|
|
61
|
-
* The column name.
|
|
62
|
-
* @type {string}
|
|
63
|
-
* @readonly
|
|
64
|
-
*/
|
|
65
57
|
this.name = name;
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
/**
|
|
69
61
|
* Returns the column name.
|
|
70
|
-
* @returns {string}
|
|
71
62
|
*/
|
|
72
63
|
get column() {
|
|
73
64
|
return this.name;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FRAGMENT } from '../constants.js';
|
|
2
|
+
import { ExprNode } from './node.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A SQL AST node made up of disjoint fragments that are combined to form
|
|
6
|
+
* a coherent expression. Along with verbatim content, this class serves
|
|
7
|
+
* as an "escape hatch" for handling more unstructured SQL content.
|
|
8
|
+
*/
|
|
9
|
+
export class FragmentNode extends ExprNode {
|
|
10
|
+
/** The consecutive parts making up the fragment. */
|
|
11
|
+
readonly spans: ExprNode[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Instantiate a fragment node with arbitrary content.
|
|
15
|
+
* @param spans The consecutive parts making up the fragment.
|
|
16
|
+
*/
|
|
17
|
+
constructor(spans: ExprNode[]) {
|
|
18
|
+
super(FRAGMENT);
|
|
19
|
+
this.spans = spans;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generate a SQL query string for this node.
|
|
24
|
+
*/
|
|
25
|
+
toString() {
|
|
26
|
+
return this.spans.join('');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { SampleClauseNode } from './sample.js';
|
|
2
2
|
import { FROM_CLAUSE } from '../constants.js';
|
|
3
3
|
import { quoteIdentifier } from '../util/string.js';
|
|
4
4
|
import { SQLNode } from './node.js';
|
|
@@ -6,37 +6,28 @@ import { isQuery } from './query.js';
|
|
|
6
6
|
import { isTableRef } from './table-ref.js';
|
|
7
7
|
|
|
8
8
|
export class FromClauseNode extends SQLNode {
|
|
9
|
+
/** The from expression. */
|
|
10
|
+
readonly expr: SQLNode;
|
|
11
|
+
/** The output name. */
|
|
12
|
+
readonly alias?: string;
|
|
13
|
+
/** The table sample. */
|
|
14
|
+
readonly sample?: SampleClauseNode;
|
|
15
|
+
|
|
9
16
|
/**
|
|
10
17
|
* Instantiate a from node.
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
18
|
+
* @param expr The from expression.
|
|
19
|
+
* @param alias The output name.
|
|
20
|
+
* @param sample The table sample.
|
|
14
21
|
*/
|
|
15
|
-
constructor(expr, alias, sample) {
|
|
22
|
+
constructor(expr: SQLNode, alias?: string, sample?: SampleClauseNode) {
|
|
16
23
|
super(FROM_CLAUSE);
|
|
17
|
-
/**
|
|
18
|
-
* The from expression.
|
|
19
|
-
* @type {SQLNode}
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
22
24
|
this.expr = expr;
|
|
23
|
-
/**
|
|
24
|
-
* The output name.
|
|
25
|
-
* @type {string}
|
|
26
|
-
* @readonly
|
|
27
|
-
*/
|
|
28
25
|
this.alias = alias;
|
|
29
|
-
/**
|
|
30
|
-
* The table sample.
|
|
31
|
-
* @type {SampleClauseNode}
|
|
32
|
-
* @readonly
|
|
33
|
-
*/
|
|
34
26
|
this.sample = sample;
|
|
35
27
|
}
|
|
36
28
|
|
|
37
29
|
/**
|
|
38
30
|
* Generate a SQL query string for this node.
|
|
39
|
-
* @returns {string}
|
|
40
31
|
*/
|
|
41
32
|
toString() {
|
|
42
33
|
const { expr, alias, sample } = this;
|
|
@@ -2,30 +2,24 @@ import { FUNCTION } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class FunctionNode extends ExprNode {
|
|
5
|
+
/** The function name. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** The function arguments. */
|
|
8
|
+
readonly args: ExprNode[];
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Instantiate a function node.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
12
|
+
* @param name The function name.
|
|
13
|
+
* @param args The function arguments.
|
|
9
14
|
*/
|
|
10
|
-
constructor(name, args = []) {
|
|
15
|
+
constructor(name: string, args: ExprNode[] = []) {
|
|
11
16
|
super(FUNCTION);
|
|
12
|
-
/**
|
|
13
|
-
* The function name.
|
|
14
|
-
* @type {string}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
17
|
this.name = name;
|
|
18
|
-
/**
|
|
19
|
-
* The function arguments.
|
|
20
|
-
* @type {ExprNode[]}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
18
|
this.args = args;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
27
22
|
* Generate a SQL query string for this node.
|
|
28
|
-
* @returns {string}
|
|
29
23
|
*/
|
|
30
24
|
toString() {
|
|
31
25
|
const { name, args } = this;
|
|
@@ -2,30 +2,24 @@ import { IN_OPERATOR } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class InOpNode extends ExprNode {
|
|
5
|
+
/** The input expression. */
|
|
6
|
+
readonly expr: ExprNode;
|
|
7
|
+
/** The value set. */
|
|
8
|
+
readonly values: ExprNode[];
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Instantiate an in operator node.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
12
|
+
* @param expr The input expression.
|
|
13
|
+
* @param values The value set.
|
|
9
14
|
*/
|
|
10
|
-
constructor(expr, values) {
|
|
15
|
+
constructor(expr: ExprNode, values: ExprNode[]) {
|
|
11
16
|
super(IN_OPERATOR);
|
|
12
|
-
/**
|
|
13
|
-
* The input expression.
|
|
14
|
-
* @type {ExprNode}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
17
|
this.expr = expr;
|
|
18
|
-
/**
|
|
19
|
-
* The value set.
|
|
20
|
-
* @type {ExprNode[]}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
18
|
this.values = values;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
27
22
|
* Generate a SQL query string for this node.
|
|
28
|
-
* @returns {string}
|
|
29
23
|
*/
|
|
30
24
|
toString() {
|
|
31
25
|
return `(${this.expr} IN (${this.values.join(', ')}))`;
|
|
@@ -2,30 +2,24 @@ import { INTERVAL } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class IntervalNode extends ExprNode {
|
|
5
|
+
/** The interval name. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** The interval steps. */
|
|
8
|
+
readonly steps: number;
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Instantiate an interval node.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
12
|
+
* @param name The interval name.
|
|
13
|
+
* @param steps The interval steps.
|
|
9
14
|
*/
|
|
10
|
-
constructor(name, steps = 1) {
|
|
15
|
+
constructor(name: string, steps: number = 1) {
|
|
11
16
|
super(INTERVAL);
|
|
12
|
-
/**
|
|
13
|
-
* The interval name.
|
|
14
|
-
* @type {string}
|
|
15
|
-
* @readonly
|
|
16
|
-
*/
|
|
17
17
|
this.name = name;
|
|
18
|
-
/**
|
|
19
|
-
* The interval steps.
|
|
20
|
-
* @type {number}
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
18
|
this.steps = steps;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
27
22
|
* Generate a SQL query string for this node.
|
|
28
|
-
* @returns {string}
|
|
29
23
|
*/
|
|
30
24
|
toString() {
|
|
31
25
|
return `INTERVAL ${this.steps} ${this.name}`;
|
package/src/ast/list.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LIST } from '../constants.js';
|
|
2
|
+
import { ExprNode } from './node.js';
|
|
3
|
+
|
|
4
|
+
export class ListNode extends ExprNode {
|
|
5
|
+
/** The array of values. */
|
|
6
|
+
readonly values: ExprNode[];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Instantiate a list node.
|
|
10
|
+
* @param values
|
|
11
|
+
*/
|
|
12
|
+
constructor(values: ExprNode[]) {
|
|
13
|
+
super(LIST);
|
|
14
|
+
this.values = values;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate a SQL query string for this node.
|
|
19
|
+
*/
|
|
20
|
+
toString() {
|
|
21
|
+
return `[${this.values.join(', ')}]`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -2,30 +2,27 @@ import { LITERAL } from '../constants.js';
|
|
|
2
2
|
import { ExprNode } from './node.js';
|
|
3
3
|
|
|
4
4
|
export class LiteralNode extends ExprNode {
|
|
5
|
+
/** The literal value. */
|
|
6
|
+
readonly value: unknown;
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Instantiate an literal node.
|
|
7
|
-
* @param
|
|
10
|
+
* @param value The literal value.
|
|
8
11
|
*/
|
|
9
|
-
constructor(value) {
|
|
12
|
+
constructor(value: unknown) {
|
|
10
13
|
super(LITERAL);
|
|
11
|
-
/**
|
|
12
|
-
* The literal value.
|
|
13
|
-
* @type {any}
|
|
14
|
-
* @readonly
|
|
15
|
-
*/
|
|
16
14
|
this.value = value;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* Generate a SQL query string for this node.
|
|
21
|
-
* @returns {string}
|
|
22
19
|
*/
|
|
23
20
|
toString() {
|
|
24
21
|
return literalToSQL(this.value);
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
export function literalToSQL(value) {
|
|
25
|
+
export function literalToSQL(value: unknown) {
|
|
29
26
|
switch (typeof value) {
|
|
30
27
|
case 'number':
|
|
31
28
|
return Number.isFinite(value) ? `${value}` : 'NULL';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LOGICAL_OPERATOR } from '../constants.js';
|
|
2
|
+
import { ExprNode } from './node.js';
|
|
3
|
+
|
|
4
|
+
export class LogicalOpNode<T extends ExprNode> extends ExprNode {
|
|
5
|
+
/** The logical operator */
|
|
6
|
+
readonly op: string;
|
|
7
|
+
/** The clause expressions. */
|
|
8
|
+
readonly clauses: T[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Instantiate a logical operator node.
|
|
12
|
+
* @param op The logical operation.
|
|
13
|
+
* @param clauses The input clause expressions.
|
|
14
|
+
*/
|
|
15
|
+
constructor(op: string, clauses: T[]) {
|
|
16
|
+
super(LOGICAL_OPERATOR);
|
|
17
|
+
this.op = op;
|
|
18
|
+
this.clauses = clauses;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate a SQL query string for this node.
|
|
23
|
+
*/
|
|
24
|
+
toString() {
|
|
25
|
+
const c = this.clauses;
|
|
26
|
+
return c.length === 0 ? ''
|
|
27
|
+
: c.length === 1 ? `${c[0]}`
|
|
28
|
+
: `(${c.join(` ${this.op} `)})`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class AndNode<T extends ExprNode> extends LogicalOpNode<T> {
|
|
33
|
+
/**
|
|
34
|
+
* Instantiate a logical AND operator node.
|
|
35
|
+
* @param clauses The input clause expressions.
|
|
36
|
+
*/
|
|
37
|
+
constructor(clauses: T[]) {
|
|
38
|
+
super('AND', clauses);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class OrNode<T extends ExprNode> extends LogicalOpNode<T> {
|
|
43
|
+
/**
|
|
44
|
+
* Instantiate a logical OR operator node.
|
|
45
|
+
* @param clauses The input clause expressions.
|
|
46
|
+
*/
|
|
47
|
+
constructor(clauses: T[]) {
|
|
48
|
+
super('OR', clauses);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Check if a value is a SQL AST node.
|
|
3
|
-
* @param
|
|
4
|
-
* @returns {value is SQLNode}
|
|
3
|
+
* @param value The value to check.
|
|
5
4
|
*/
|
|
6
|
-
export function isNode(value) {
|
|
5
|
+
export function isNode(value: unknown): value is SQLNode {
|
|
7
6
|
return value instanceof SQLNode;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export class SQLNode {
|
|
10
|
+
/** The SQL AST node type. */
|
|
11
|
+
readonly type: string;
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* Instantiate a SQL AST node.
|
|
13
|
-
* @param
|
|
15
|
+
* @param type The SQL AST node type.
|
|
14
16
|
*/
|
|
15
|
-
constructor(type) {
|
|
16
|
-
/**
|
|
17
|
-
* The SQL AST node type.
|
|
18
|
-
* @type {string}
|
|
19
|
-
* @readonly
|
|
20
|
-
*/
|
|
17
|
+
constructor(type: string) {
|
|
21
18
|
this.type = type;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* Create a shallow clone of this SQL AST node.
|
|
26
|
-
* @returns
|
|
23
|
+
* @returns The shallow clone node.
|
|
27
24
|
*/
|
|
28
|
-
clone() {
|
|
29
|
-
// @ts-expect-error
|
|
25
|
+
clone(): this {
|
|
26
|
+
// @ts-expect-error use constructor
|
|
30
27
|
const clone = new this.constructor();
|
|
31
28
|
for (const key in this) {
|
|
32
29
|
clone[key] = this[key];
|