@quereus/quereus 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/dist/src/common/constants.js.map +0 -1
- package/dist/src/common/datatype.js.map +0 -1
- package/dist/src/common/errors.js.map +0 -1
- package/dist/src/common/json-types.js.map +0 -1
- package/dist/src/common/logger.js.map +0 -1
- package/dist/src/common/type-inference.js.map +0 -1
- package/dist/src/common/types.js.map +0 -1
- package/dist/src/core/database-options.js.map +0 -1
- package/dist/src/core/database.js.map +0 -1
- package/dist/src/core/param.js.map +0 -1
- package/dist/src/core/statement.js.map +0 -1
- package/dist/src/func/builtins/aggregate.js.map +0 -1
- package/dist/src/func/builtins/builtin-window-functions.js.map +0 -1
- package/dist/src/func/builtins/conversion.js.map +0 -1
- package/dist/src/func/builtins/datetime.js.map +0 -1
- package/dist/src/func/builtins/explain.js.map +0 -1
- package/dist/src/func/builtins/generation.js.map +0 -1
- package/dist/src/func/builtins/index.js.map +0 -1
- package/dist/src/func/builtins/json-helpers.js.map +0 -1
- package/dist/src/func/builtins/json-tvf.js.map +0 -1
- package/dist/src/func/builtins/json.js.map +0 -1
- package/dist/src/func/builtins/scalar.js.map +0 -1
- package/dist/src/func/builtins/schema.js.map +0 -1
- package/dist/src/func/builtins/string.js.map +0 -1
- package/dist/src/func/builtins/timespan.js.map +0 -1
- package/dist/src/func/context.js.map +0 -1
- package/dist/src/func/registration.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/index.js.map +0 -1
- package/dist/src/parser/lexer.js.map +0 -1
- package/dist/src/parser/parser.js.map +0 -1
- package/dist/src/parser/utils.js.map +0 -1
- package/dist/src/parser/visitor.js.map +0 -1
- package/dist/src/planner/analysis/binding-collector.js.map +0 -1
- package/dist/src/planner/analysis/const-evaluator.js.map +0 -1
- package/dist/src/planner/analysis/const-pass.js.map +0 -1
- package/dist/src/planner/analysis/constraint-extractor.js.map +0 -1
- package/dist/src/planner/analysis/predicate-normalizer.js.map +0 -1
- package/dist/src/planner/building/alter-table.js.map +0 -1
- package/dist/src/planner/building/block.js.map +0 -1
- package/dist/src/planner/building/constraint-builder.js.map +0 -1
- package/dist/src/planner/building/create-assertion.js.map +0 -1
- package/dist/src/planner/building/create-view.js.map +0 -1
- package/dist/src/planner/building/ddl.js.map +0 -1
- package/dist/src/planner/building/declare-schema.js.map +0 -1
- package/dist/src/planner/building/delete.js.map +0 -1
- package/dist/src/planner/building/drop-assertion.js.map +0 -1
- package/dist/src/planner/building/drop-table.js.map +0 -1
- package/dist/src/planner/building/drop-view.js.map +0 -1
- package/dist/src/planner/building/expression.js.map +0 -1
- package/dist/src/planner/building/function-call.js.map +0 -1
- package/dist/src/planner/building/insert.js.map +0 -1
- package/dist/src/planner/building/pragma.js.map +0 -1
- package/dist/src/planner/building/schema-resolution.js.map +0 -1
- package/dist/src/planner/building/select-aggregates.js.map +0 -1
- package/dist/src/planner/building/select-compound.js.map +0 -1
- package/dist/src/planner/building/select-context.js.map +0 -1
- package/dist/src/planner/building/select-modifiers.js.map +0 -1
- package/dist/src/planner/building/select-projections.js.map +0 -1
- package/dist/src/planner/building/select-window.js.map +0 -1
- package/dist/src/planner/building/select.js.map +0 -1
- package/dist/src/planner/building/table-function.js.map +0 -1
- package/dist/src/planner/building/table.js.map +0 -1
- package/dist/src/planner/building/transaction.js.map +0 -1
- package/dist/src/planner/building/update.js.map +0 -1
- package/dist/src/planner/building/with.js.map +0 -1
- package/dist/src/planner/cache/correlation-detector.js.map +0 -1
- package/dist/src/planner/cache/materialization-advisory.js.map +0 -1
- package/dist/src/planner/cache/reference-graph.js.map +0 -1
- package/dist/src/planner/cost/index.js.map +0 -1
- package/dist/src/planner/debug/logger-utils.js.map +0 -1
- package/dist/src/planner/debug.js.map +0 -1
- package/dist/src/planner/framework/characteristics.js.map +0 -1
- package/dist/src/planner/framework/context.js.map +0 -1
- package/dist/src/planner/framework/pass.js.map +0 -1
- package/dist/src/planner/framework/physical-utils.js.map +0 -1
- package/dist/src/planner/framework/registry.js.map +0 -1
- package/dist/src/planner/framework/trace.js.map +0 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-function.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-node.js.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/planner/nodes/block.js.map +0 -1
- package/dist/src/planner/nodes/cache-node.js.map +0 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +0 -1
- package/dist/src/planner/nodes/create-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/create-index-node.js.map +0 -1
- package/dist/src/planner/nodes/create-table-node.js.map +0 -1
- package/dist/src/planner/nodes/create-view-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/declarative-schema.js.map +0 -1
- package/dist/src/planner/nodes/delete-node.js.map +0 -1
- package/dist/src/planner/nodes/distinct-node.js.map +0 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-table-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-view-node.js.map +0 -1
- package/dist/src/planner/nodes/filter.js.map +0 -1
- package/dist/src/planner/nodes/function.js.map +0 -1
- package/dist/src/planner/nodes/insert-node.js.map +0 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +0 -1
- package/dist/src/planner/nodes/join-node.js.map +0 -1
- package/dist/src/planner/nodes/limit-offset.js.map +0 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +0 -1
- package/dist/src/planner/nodes/plan-node.js.map +0 -1
- package/dist/src/planner/nodes/pragma.js.map +0 -1
- package/dist/src/planner/nodes/project-node.js.map +0 -1
- package/dist/src/planner/nodes/recursive-cte-node.js.map +0 -1
- package/dist/src/planner/nodes/reference.js.map +0 -1
- package/dist/src/planner/nodes/remote-query-node.js.map +0 -1
- package/dist/src/planner/nodes/retrieve-node.js.map +0 -1
- package/dist/src/planner/nodes/returning-node.js.map +0 -1
- package/dist/src/planner/nodes/scalar.js.map +0 -1
- package/dist/src/planner/nodes/sequencing-node.js.map +0 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +0 -1
- package/dist/src/planner/nodes/single-row.js.map +0 -1
- package/dist/src/planner/nodes/sink-node.js.map +0 -1
- package/dist/src/planner/nodes/sort.js.map +0 -1
- package/dist/src/planner/nodes/stream-aggregate.js.map +0 -1
- package/dist/src/planner/nodes/subquery.js.map +0 -1
- package/dist/src/planner/nodes/table-access-nodes.js.map +0 -1
- package/dist/src/planner/nodes/table-function-call.js.map +0 -1
- package/dist/src/planner/nodes/transaction-node.js.map +0 -1
- package/dist/src/planner/nodes/update-node.js.map +0 -1
- package/dist/src/planner/nodes/values-node.js.map +0 -1
- package/dist/src/planner/nodes/view-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/window-function.js.map +0 -1
- package/dist/src/planner/nodes/window-node.js.map +0 -1
- package/dist/src/planner/optimizer-tuning.js.map +0 -1
- package/dist/src/planner/optimizer.js.map +0 -1
- package/dist/src/planner/planning-context.js.map +0 -1
- package/dist/src/planner/resolve.js.map +0 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +0 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +0 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +0 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +0 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +0 -1
- package/dist/src/planner/scopes/aliased.js.map +0 -1
- package/dist/src/planner/scopes/base.js.map +0 -1
- package/dist/src/planner/scopes/empty.js.map +0 -1
- package/dist/src/planner/scopes/global.js.map +0 -1
- package/dist/src/planner/scopes/multi.js.map +0 -1
- package/dist/src/planner/scopes/param.js.map +0 -1
- package/dist/src/planner/scopes/registered.js.map +0 -1
- package/dist/src/planner/scopes/scope.js.map +0 -1
- package/dist/src/planner/stats/basic-estimates.js.map +0 -1
- package/dist/src/planner/stats/index.js.map +0 -1
- package/dist/src/planner/type-utils.js.map +0 -1
- package/dist/src/planner/util/key-utils.js.map +0 -1
- package/dist/src/planner/validation/determinism-validator.js.map +0 -1
- package/dist/src/planner/validation/plan-validator.js.map +0 -1
- package/dist/src/runtime/async-util.js.map +0 -1
- package/dist/src/runtime/cache/shared-cache.js.map +0 -1
- package/dist/src/runtime/context-helpers.js.map +0 -1
- package/dist/src/runtime/deferred-constraint-queue.js.map +0 -1
- package/dist/src/runtime/emission-context.js.map +0 -1
- package/dist/src/runtime/emit/add-constraint.js.map +0 -1
- package/dist/src/runtime/emit/aggregate.js.map +0 -1
- package/dist/src/runtime/emit/array-index.js.map +0 -1
- package/dist/src/runtime/emit/between.js.map +0 -1
- package/dist/src/runtime/emit/binary.js.map +0 -1
- package/dist/src/runtime/emit/block.js.map +0 -1
- package/dist/src/runtime/emit/cache.js.map +0 -1
- package/dist/src/runtime/emit/case.js.map +0 -1
- package/dist/src/runtime/emit/cast.js.map +0 -1
- package/dist/src/runtime/emit/collate.js.map +0 -1
- package/dist/src/runtime/emit/column-reference.js.map +0 -1
- package/dist/src/runtime/emit/constraint-check.js.map +0 -1
- package/dist/src/runtime/emit/create-assertion.js.map +0 -1
- package/dist/src/runtime/emit/create-index.js.map +0 -1
- package/dist/src/runtime/emit/create-table.js.map +0 -1
- package/dist/src/runtime/emit/create-view.js.map +0 -1
- package/dist/src/runtime/emit/cte-reference.js.map +0 -1
- package/dist/src/runtime/emit/cte.js.map +0 -1
- package/dist/src/runtime/emit/delete.js.map +0 -1
- package/dist/src/runtime/emit/distinct.js.map +0 -1
- package/dist/src/runtime/emit/dml-executor.js.map +0 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +0 -1
- package/dist/src/runtime/emit/drop-table.js.map +0 -1
- package/dist/src/runtime/emit/drop-view.js.map +0 -1
- package/dist/src/runtime/emit/filter.js.map +0 -1
- package/dist/src/runtime/emit/insert.js.map +0 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +0 -1
- package/dist/src/runtime/emit/join.js.map +0 -1
- package/dist/src/runtime/emit/limit-offset.js.map +0 -1
- package/dist/src/runtime/emit/literal.js.map +0 -1
- package/dist/src/runtime/emit/parameter.js.map +0 -1
- package/dist/src/runtime/emit/pragma.js.map +0 -1
- package/dist/src/runtime/emit/project.js.map +0 -1
- package/dist/src/runtime/emit/recursive-cte.js.map +0 -1
- package/dist/src/runtime/emit/remote-query.js.map +0 -1
- package/dist/src/runtime/emit/retrieve.js.map +0 -1
- package/dist/src/runtime/emit/returning.js.map +0 -1
- package/dist/src/runtime/emit/scalar-function.js.map +0 -1
- package/dist/src/runtime/emit/scan.js.map +0 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +0 -1
- package/dist/src/runtime/emit/sequencing.js.map +0 -1
- package/dist/src/runtime/emit/set-operation.js.map +0 -1
- package/dist/src/runtime/emit/sink.js.map +0 -1
- package/dist/src/runtime/emit/sort.js.map +0 -1
- package/dist/src/runtime/emit/subquery.js.map +0 -1
- package/dist/src/runtime/emit/table-valued-function.js.map +0 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +0 -1
- package/dist/src/runtime/emit/transaction.js.map +0 -1
- package/dist/src/runtime/emit/unary.js.map +0 -1
- package/dist/src/runtime/emit/update.js.map +0 -1
- package/dist/src/runtime/emit/values.js.map +0 -1
- package/dist/src/runtime/emit/window-function.js.map +0 -1
- package/dist/src/runtime/emit/window.js.map +0 -1
- package/dist/src/runtime/emitters.js.map +0 -1
- package/dist/src/runtime/register.js.map +0 -1
- package/dist/src/runtime/scheduler.js.map +0 -1
- package/dist/src/runtime/types.js.map +0 -1
- package/dist/src/runtime/utils.js.map +0 -1
- package/dist/src/schema/assertion.js.map +0 -1
- package/dist/src/schema/catalog.js.map +0 -1
- package/dist/src/schema/change-events.js.map +0 -1
- package/dist/src/schema/column.js.map +0 -1
- package/dist/src/schema/declared-schema-manager.js.map +0 -1
- package/dist/src/schema/function.js.map +0 -1
- package/dist/src/schema/manager.js.map +0 -1
- package/dist/src/schema/schema-differ.js.map +0 -1
- package/dist/src/schema/schema-hasher.js.map +0 -1
- package/dist/src/schema/schema.js.map +0 -1
- package/dist/src/schema/table.js.map +0 -1
- package/dist/src/schema/view.js.map +0 -1
- package/dist/src/schema/window-function.js.map +0 -1
- package/dist/src/types/builtin-types.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/json-type.js.map +0 -1
- package/dist/src/types/logical-type.js.map +0 -1
- package/dist/src/types/plugin-interface.js.map +0 -1
- package/dist/src/types/registry.js.map +0 -1
- package/dist/src/types/temporal-types.js.map +0 -1
- package/dist/src/types/validation.js.map +0 -1
- package/dist/src/util/affinity.js.map +0 -1
- package/dist/src/util/ast-stringify.js.map +0 -1
- package/dist/src/util/cached.js.map +0 -1
- package/dist/src/util/coercion.js.map +0 -1
- package/dist/src/util/comparison.js.map +0 -1
- package/dist/src/util/environment.js.map +0 -1
- package/dist/src/util/hash.js.map +0 -1
- package/dist/src/util/latches.js.map +0 -1
- package/dist/src/util/mutation-statement.js.map +0 -1
- package/dist/src/util/patterns.js.map +0 -1
- package/dist/src/util/plan-formatter.js.map +0 -1
- package/dist/src/util/plugin-helper.js.map +0 -1
- package/dist/src/util/row-descriptor.js.map +0 -1
- package/dist/src/util/serialization.js.map +0 -1
- package/dist/src/util/sql-literal.js.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
- package/dist/src/vtab/best-access-plan.js.map +0 -1
- package/dist/src/vtab/connection.js.map +0 -1
- package/dist/src/vtab/filter-info.js.map +0 -1
- package/dist/src/vtab/index-info.js.map +0 -1
- package/dist/src/vtab/manifest.js.map +0 -1
- package/dist/src/vtab/memory/connection.js.map +0 -1
- package/dist/src/vtab/memory/index.js.map +0 -1
- package/dist/src/vtab/memory/layer/base-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/base.js.map +0 -1
- package/dist/src/vtab/memory/layer/connection.js.map +0 -1
- package/dist/src/vtab/memory/layer/interface.js.map +0 -1
- package/dist/src/vtab/memory/layer/manager.js.map +0 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +0 -1
- package/dist/src/vtab/memory/layer/scan-plan.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction.js.map +0 -1
- package/dist/src/vtab/memory/module.js.map +0 -1
- package/dist/src/vtab/memory/table.js.map +0 -1
- package/dist/src/vtab/memory/types.js.map +0 -1
- package/dist/src/vtab/memory/utils/logging.js.map +0 -1
- package/dist/src/vtab/memory/utils/primary-key.js.map +0 -1
- package/dist/src/vtab/module.js.map +0 -1
- package/dist/src/vtab/table.js.map +0 -1
- package/src/common/constants.ts +0 -60
- package/src/common/datatype.ts +0 -85
- package/src/common/errors.ts +0 -189
- package/src/common/json-types.ts +0 -16
- package/src/common/logger.ts +0 -97
- package/src/common/type-inference.ts +0 -39
- package/src/common/types.ts +0 -151
- package/src/core/database-options.ts +0 -258
- package/src/core/database.ts +0 -1461
- package/src/core/param.ts +0 -56
- package/src/core/statement.ts +0 -528
- package/src/func/builtins/aggregate.ts +0 -269
- package/src/func/builtins/builtin-window-functions.ts +0 -166
- package/src/func/builtins/conversion.ts +0 -226
- package/src/func/builtins/datetime.ts +0 -500
- package/src/func/builtins/explain.ts +0 -779
- package/src/func/builtins/generation.ts +0 -43
- package/src/func/builtins/index.ts +0 -167
- package/src/func/builtins/json-helpers.ts +0 -237
- package/src/func/builtins/json-tvf.ts +0 -224
- package/src/func/builtins/json.ts +0 -588
- package/src/func/builtins/scalar.ts +0 -423
- package/src/func/builtins/schema.ts +0 -213
- package/src/func/builtins/string.ts +0 -306
- package/src/func/builtins/timespan.ts +0 -179
- package/src/func/context.ts +0 -258
- package/src/func/registration.ts +0 -201
- package/src/index.ts +0 -172
- package/src/parser/ast.ts +0 -581
- package/src/parser/index.ts +0 -65
- package/src/parser/lexer.ts +0 -806
- package/src/parser/parser.ts +0 -3352
- package/src/parser/utils.ts +0 -10
- package/src/parser/visitor.ts +0 -188
- package/src/planner/analysis/README.md +0 -93
- package/src/planner/analysis/binding-collector.ts +0 -83
- package/src/planner/analysis/const-evaluator.ts +0 -63
- package/src/planner/analysis/const-pass.ts +0 -282
- package/src/planner/analysis/constraint-extractor.ts +0 -764
- package/src/planner/analysis/predicate-normalizer.ts +0 -237
- package/src/planner/building/alter-table.ts +0 -49
- package/src/planner/building/block.ts +0 -93
- package/src/planner/building/constraint-builder.ts +0 -178
- package/src/planner/building/create-assertion.ts +0 -7
- package/src/planner/building/create-view.ts +0 -29
- package/src/planner/building/ddl.ts +0 -24
- package/src/planner/building/declare-schema.ts +0 -22
- package/src/planner/building/delete.ts +0 -218
- package/src/planner/building/drop-assertion.ts +0 -11
- package/src/planner/building/drop-table.ts +0 -13
- package/src/planner/building/drop-view.ts +0 -19
- package/src/planner/building/expression.ts +0 -205
- package/src/planner/building/function-call.ts +0 -129
- package/src/planner/building/insert.ts +0 -435
- package/src/planner/building/pragma.ts +0 -34
- package/src/planner/building/schema-resolution.ts +0 -176
- package/src/planner/building/select-aggregates.ts +0 -318
- package/src/planner/building/select-compound.ts +0 -119
- package/src/planner/building/select-context.ts +0 -85
- package/src/planner/building/select-modifiers.ts +0 -236
- package/src/planner/building/select-projections.ts +0 -177
- package/src/planner/building/select-window.ts +0 -259
- package/src/planner/building/select.ts +0 -567
- package/src/planner/building/table-function.ts +0 -49
- package/src/planner/building/table.ts +0 -40
- package/src/planner/building/transaction.ts +0 -23
- package/src/planner/building/update.ts +0 -331
- package/src/planner/building/with.ts +0 -180
- package/src/planner/cache/correlation-detector.ts +0 -83
- package/src/planner/cache/materialization-advisory.ts +0 -265
- package/src/planner/cache/reference-graph.ts +0 -196
- package/src/planner/cost/index.ts +0 -169
- package/src/planner/debug/logger-utils.ts +0 -68
- package/src/planner/debug.ts +0 -480
- package/src/planner/framework/README.md +0 -132
- package/src/planner/framework/characteristics.ts +0 -503
- package/src/planner/framework/context.ts +0 -239
- package/src/planner/framework/pass.ts +0 -354
- package/src/planner/framework/physical-utils.ts +0 -210
- package/src/planner/framework/registry.ts +0 -261
- package/src/planner/framework/trace.ts +0 -259
- package/src/planner/nodes/add-constraint-node.ts +0 -62
- package/src/planner/nodes/aggregate-function.ts +0 -155
- package/src/planner/nodes/aggregate-node.ts +0 -267
- package/src/planner/nodes/array-index-node.ts +0 -50
- package/src/planner/nodes/block.ts +0 -80
- package/src/planner/nodes/cache-node.ts +0 -103
- package/src/planner/nodes/constraint-check-node.ts +0 -138
- package/src/planner/nodes/create-assertion-node.ts +0 -51
- package/src/planner/nodes/create-index-node.ts +0 -41
- package/src/planner/nodes/create-table-node.ts +0 -35
- package/src/planner/nodes/create-view-node.ts +0 -44
- package/src/planner/nodes/cte-node.ts +0 -168
- package/src/planner/nodes/cte-reference-node.ts +0 -125
- package/src/planner/nodes/declarative-schema.ts +0 -221
- package/src/planner/nodes/delete-node.ts +0 -102
- package/src/planner/nodes/distinct-node.ts +0 -107
- package/src/planner/nodes/dml-executor-node.ts +0 -104
- package/src/planner/nodes/drop-assertion-node.ts +0 -50
- package/src/planner/nodes/drop-table-node.ts +0 -36
- package/src/planner/nodes/drop-view-node.ts +0 -37
- package/src/planner/nodes/filter.ts +0 -144
- package/src/planner/nodes/function.ts +0 -98
- package/src/planner/nodes/insert-node.ts +0 -126
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +0 -61
- package/src/planner/nodes/join-node.ts +0 -336
- package/src/planner/nodes/limit-offset.ts +0 -144
- package/src/planner/nodes/plan-node-type.ts +0 -95
- package/src/planner/nodes/plan-node.ts +0 -503
- package/src/planner/nodes/pragma.ts +0 -98
- package/src/planner/nodes/project-node.ts +0 -337
- package/src/planner/nodes/recursive-cte-node.ts +0 -158
- package/src/planner/nodes/reference.ts +0 -334
- package/src/planner/nodes/remote-query-node.ts +0 -73
- package/src/planner/nodes/retrieve-node.ts +0 -86
- package/src/planner/nodes/returning-node.ts +0 -269
- package/src/planner/nodes/scalar.ts +0 -772
- package/src/planner/nodes/sequencing-node.ts +0 -113
- package/src/planner/nodes/set-operation-node.ts +0 -87
- package/src/planner/nodes/single-row.ts +0 -85
- package/src/planner/nodes/sink-node.ts +0 -61
- package/src/planner/nodes/sort.ts +0 -166
- package/src/planner/nodes/stream-aggregate.ts +0 -293
- package/src/planner/nodes/subquery.ts +0 -268
- package/src/planner/nodes/table-access-nodes.ts +0 -323
- package/src/planner/nodes/table-function-call.ts +0 -134
- package/src/planner/nodes/transaction-node.ts +0 -55
- package/src/planner/nodes/update-node.ts +0 -138
- package/src/planner/nodes/values-node.ts +0 -244
- package/src/planner/nodes/view-reference-node.ts +0 -97
- package/src/planner/nodes/window-function.ts +0 -73
- package/src/planner/nodes/window-node.ts +0 -199
- package/src/planner/optimizer-tuning.ts +0 -105
- package/src/planner/optimizer.ts +0 -332
- package/src/planner/planning-context.ts +0 -190
- package/src/planner/resolve.ts +0 -101
- package/src/planner/rules/README.md +0 -96
- package/src/planner/rules/access/rule-select-access-path.ts +0 -399
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +0 -162
- package/src/planner/rules/cache/rule-cte-optimization.ts +0 -79
- package/src/planner/rules/cache/rule-materialization-advisory.ts +0 -77
- package/src/planner/rules/cache/rule-mutating-subquery-cache.ts +0 -104
- package/src/planner/rules/join/rule-join-greedy-commute.ts +0 -48
- package/src/planner/rules/join/rule-join-key-inference.ts +0 -35
- package/src/planner/rules/join/rule-quickpick-enumeration.ts +0 -267
- package/src/planner/rules/predicate/rule-predicate-pushdown.ts +0 -144
- package/src/planner/rules/retrieve/rule-grow-retrieve.ts +0 -337
- package/src/planner/scopes/aliased.ts +0 -50
- package/src/planner/scopes/base.ts +0 -10
- package/src/planner/scopes/empty.ts +0 -12
- package/src/planner/scopes/global.ts +0 -73
- package/src/planner/scopes/multi.ts +0 -40
- package/src/planner/scopes/param.ts +0 -95
- package/src/planner/scopes/registered.ts +0 -67
- package/src/planner/scopes/scope.ts +0 -16
- package/src/planner/stats/basic-estimates.ts +0 -107
- package/src/planner/stats/index.ts +0 -158
- package/src/planner/type-utils.ts +0 -87
- package/src/planner/util/key-utils.ts +0 -46
- package/src/planner/validation/determinism-validator.ts +0 -104
- package/src/planner/validation/plan-validator.ts +0 -335
- package/src/runtime/async-util.ts +0 -283
- package/src/runtime/cache/shared-cache.ts +0 -169
- package/src/runtime/context-helpers.ts +0 -191
- package/src/runtime/deferred-constraint-queue.ts +0 -196
- package/src/runtime/emission-context.ts +0 -319
- package/src/runtime/emit/add-constraint.ts +0 -78
- package/src/runtime/emit/aggregate.ts +0 -581
- package/src/runtime/emit/array-index.ts +0 -25
- package/src/runtime/emit/between.ts +0 -51
- package/src/runtime/emit/binary.ts +0 -357
- package/src/runtime/emit/block.ts +0 -23
- package/src/runtime/emit/cache.ts +0 -64
- package/src/runtime/emit/case.ts +0 -87
- package/src/runtime/emit/cast.ts +0 -151
- package/src/runtime/emit/collate.ts +0 -9
- package/src/runtime/emit/column-reference.ts +0 -17
- package/src/runtime/emit/constraint-check.ts +0 -290
- package/src/runtime/emit/create-assertion.ts +0 -82
- package/src/runtime/emit/create-index.ts +0 -15
- package/src/runtime/emit/create-table.ts +0 -15
- package/src/runtime/emit/create-view.ts +0 -52
- package/src/runtime/emit/cte-reference.ts +0 -38
- package/src/runtime/emit/cte.ts +0 -39
- package/src/runtime/emit/delete.ts +0 -24
- package/src/runtime/emit/distinct.ts +0 -40
- package/src/runtime/emit/dml-executor.ts +0 -198
- package/src/runtime/emit/drop-assertion.ts +0 -45
- package/src/runtime/emit/drop-table.ts +0 -27
- package/src/runtime/emit/drop-view.ts +0 -49
- package/src/runtime/emit/filter.ts +0 -30
- package/src/runtime/emit/insert.ts +0 -42
- package/src/runtime/emit/internal-recursive-cte-ref.ts +0 -37
- package/src/runtime/emit/join.ts +0 -148
- package/src/runtime/emit/limit-offset.ts +0 -73
- package/src/runtime/emit/literal.ts +0 -17
- package/src/runtime/emit/parameter.ts +0 -59
- package/src/runtime/emit/pragma.ts +0 -56
- package/src/runtime/emit/project.ts +0 -46
- package/src/runtime/emit/recursive-cte.ts +0 -111
- package/src/runtime/emit/remote-query.ts +0 -47
- package/src/runtime/emit/retrieve.ts +0 -15
- package/src/runtime/emit/returning.ts +0 -41
- package/src/runtime/emit/scalar-function.ts +0 -69
- package/src/runtime/emit/scan.ts +0 -106
- package/src/runtime/emit/schema-declarative.ts +0 -215
- package/src/runtime/emit/sequencing.ts +0 -24
- package/src/runtime/emit/set-operation.ts +0 -141
- package/src/runtime/emit/sink.ts +0 -27
- package/src/runtime/emit/sort.ts +0 -75
- package/src/runtime/emit/subquery.ts +0 -203
- package/src/runtime/emit/table-valued-function.ts +0 -106
- package/src/runtime/emit/temporal-arithmetic.ts +0 -302
- package/src/runtime/emit/transaction.ts +0 -205
- package/src/runtime/emit/unary.ts +0 -101
- package/src/runtime/emit/update.ts +0 -66
- package/src/runtime/emit/values.ts +0 -66
- package/src/runtime/emit/window-function.ts +0 -42
- package/src/runtime/emit/window.ts +0 -458
- package/src/runtime/emitters.ts +0 -183
- package/src/runtime/register.ts +0 -150
- package/src/runtime/scheduler.ts +0 -488
- package/src/runtime/types.ts +0 -242
- package/src/runtime/utils.ts +0 -177
- package/src/schema/assertion.ts +0 -21
- package/src/schema/catalog.ts +0 -269
- package/src/schema/change-events.ts +0 -80
- package/src/schema/column.ts +0 -51
- package/src/schema/declared-schema-manager.ts +0 -82
- package/src/schema/function.ts +0 -188
- package/src/schema/manager.ts +0 -1034
- package/src/schema/schema-differ.ts +0 -214
- package/src/schema/schema-hasher.ts +0 -26
- package/src/schema/schema.ts +0 -222
- package/src/schema/table.ts +0 -409
- package/src/schema/view.ts +0 -19
- package/src/schema/window-function.ts +0 -56
- package/src/types/builtin-types.ts +0 -350
- package/src/types/index.ts +0 -17
- package/src/types/json-type.ts +0 -152
- package/src/types/logical-type.ts +0 -91
- package/src/types/plugin-interface.ts +0 -10
- package/src/types/registry.ts +0 -204
- package/src/types/temporal-types.ts +0 -290
- package/src/types/validation.ts +0 -120
- package/src/util/affinity.ts +0 -151
- package/src/util/ast-stringify.ts +0 -887
- package/src/util/cached.ts +0 -25
- package/src/util/coercion.ts +0 -113
- package/src/util/comparison.ts +0 -510
- package/src/util/environment.ts +0 -52
- package/src/util/hash.ts +0 -90
- package/src/util/latches.ts +0 -47
- package/src/util/mutation-statement.ts +0 -135
- package/src/util/patterns.ts +0 -56
- package/src/util/plan-formatter.ts +0 -48
- package/src/util/plugin-helper.ts +0 -110
- package/src/util/row-descriptor.ts +0 -105
- package/src/util/serialization.ts +0 -47
- package/src/util/sql-literal.ts +0 -22
- package/src/util/working-table-iterable.ts +0 -38
- package/src/vtab/best-access-plan.ts +0 -244
- package/src/vtab/connection.ts +0 -36
- package/src/vtab/filter-info.ts +0 -23
- package/src/vtab/index-info.ts +0 -84
- package/src/vtab/manifest.ts +0 -86
- package/src/vtab/memory/connection.ts +0 -73
- package/src/vtab/memory/index.ts +0 -191
- package/src/vtab/memory/layer/base-cursor.ts +0 -124
- package/src/vtab/memory/layer/base.ts +0 -275
- package/src/vtab/memory/layer/connection.ts +0 -203
- package/src/vtab/memory/layer/interface.ts +0 -47
- package/src/vtab/memory/layer/manager.ts +0 -909
- package/src/vtab/memory/layer/safe-iterate.ts +0 -49
- package/src/vtab/memory/layer/scan-plan.ts +0 -84
- package/src/vtab/memory/layer/transaction-cursor.ts +0 -162
- package/src/vtab/memory/layer/transaction.ts +0 -229
- package/src/vtab/memory/module.ts +0 -667
- package/src/vtab/memory/table.ts +0 -251
- package/src/vtab/memory/types.ts +0 -23
- package/src/vtab/memory/utils/logging.ts +0 -36
- package/src/vtab/memory/utils/primary-key.ts +0 -163
- package/src/vtab/module.ts +0 -162
- package/src/vtab/table.ts +0 -177
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { PhysicalType, type LogicalType } from './logical-type.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* NULL type - represents null values
|
|
5
|
-
*/
|
|
6
|
-
export const NULL_TYPE: LogicalType = {
|
|
7
|
-
name: 'NULL',
|
|
8
|
-
physicalType: PhysicalType.NULL,
|
|
9
|
-
|
|
10
|
-
validate: (v) => v === null,
|
|
11
|
-
|
|
12
|
-
compare: (a, b) => {
|
|
13
|
-
// Both must be null
|
|
14
|
-
if (a === null && b === null) return 0;
|
|
15
|
-
if (a === null) return -1;
|
|
16
|
-
if (b === null) return 1;
|
|
17
|
-
return 0;
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* INTEGER type - whole numbers
|
|
23
|
-
*/
|
|
24
|
-
export const INTEGER_TYPE: LogicalType = {
|
|
25
|
-
name: 'INTEGER',
|
|
26
|
-
physicalType: PhysicalType.INTEGER,
|
|
27
|
-
isNumeric: true,
|
|
28
|
-
|
|
29
|
-
validate: (v) => {
|
|
30
|
-
if (v === null) return true;
|
|
31
|
-
if (typeof v === 'bigint') return true;
|
|
32
|
-
if (typeof v === 'number') return Number.isInteger(v) && Number.isSafeInteger(v);
|
|
33
|
-
return false;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
parse: (v) => {
|
|
37
|
-
if (v === null) return null;
|
|
38
|
-
if (typeof v === 'bigint') return v;
|
|
39
|
-
if (typeof v === 'number') {
|
|
40
|
-
if (!Number.isInteger(v)) {
|
|
41
|
-
return Math.trunc(v);
|
|
42
|
-
}
|
|
43
|
-
return v;
|
|
44
|
-
}
|
|
45
|
-
if (typeof v === 'boolean') return v ? 1 : 0;
|
|
46
|
-
if (typeof v === 'string') {
|
|
47
|
-
const trimmed = v.trim();
|
|
48
|
-
if (trimmed === '') return null;
|
|
49
|
-
const parsed = parseInt(trimmed, 10);
|
|
50
|
-
if (isNaN(parsed)) {
|
|
51
|
-
throw new TypeError(`Cannot convert '${v}' to INTEGER`);
|
|
52
|
-
}
|
|
53
|
-
return parsed;
|
|
54
|
-
}
|
|
55
|
-
throw new TypeError(`Cannot convert ${typeof v} to INTEGER`);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
compare: (a, b) => {
|
|
59
|
-
if (a === null && b === null) return 0;
|
|
60
|
-
if (a === null) return -1;
|
|
61
|
-
if (b === null) return 1;
|
|
62
|
-
|
|
63
|
-
const numA = typeof a === 'bigint' ? Number(a) : a as number;
|
|
64
|
-
const numB = typeof b === 'bigint' ? Number(b) : b as number;
|
|
65
|
-
|
|
66
|
-
return numA < numB ? -1 : numA > numB ? 1 : 0;
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* REAL type - floating point numbers
|
|
72
|
-
*/
|
|
73
|
-
export const REAL_TYPE: LogicalType = {
|
|
74
|
-
name: 'REAL',
|
|
75
|
-
physicalType: PhysicalType.REAL,
|
|
76
|
-
isNumeric: true,
|
|
77
|
-
|
|
78
|
-
validate: (v) => {
|
|
79
|
-
if (v === null) return true;
|
|
80
|
-
return typeof v === 'number';
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
parse: (v) => {
|
|
84
|
-
if (v === null) return null;
|
|
85
|
-
if (typeof v === 'number') return v;
|
|
86
|
-
if (typeof v === 'bigint') return Number(v);
|
|
87
|
-
if (typeof v === 'boolean') return v ? 1.0 : 0.0;
|
|
88
|
-
if (typeof v === 'string') {
|
|
89
|
-
const trimmed = v.trim();
|
|
90
|
-
if (trimmed === '') return null;
|
|
91
|
-
const parsed = parseFloat(trimmed);
|
|
92
|
-
if (isNaN(parsed)) {
|
|
93
|
-
throw new TypeError(`Cannot convert '${v}' to REAL`);
|
|
94
|
-
}
|
|
95
|
-
return parsed;
|
|
96
|
-
}
|
|
97
|
-
throw new TypeError(`Cannot convert ${typeof v} to REAL`);
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
compare: (a, b) => {
|
|
101
|
-
if (a === null && b === null) return 0;
|
|
102
|
-
if (a === null) return -1;
|
|
103
|
-
if (b === null) return 1;
|
|
104
|
-
|
|
105
|
-
const numA = a as number;
|
|
106
|
-
const numB = b as number;
|
|
107
|
-
|
|
108
|
-
// Handle NaN
|
|
109
|
-
if (isNaN(numA) && isNaN(numB)) return 0;
|
|
110
|
-
if (isNaN(numA)) return -1;
|
|
111
|
-
if (isNaN(numB)) return 1;
|
|
112
|
-
|
|
113
|
-
return numA < numB ? -1 : numA > numB ? 1 : 0;
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* TEXT type - strings
|
|
119
|
-
*/
|
|
120
|
-
export const TEXT_TYPE: LogicalType = {
|
|
121
|
-
name: 'TEXT',
|
|
122
|
-
physicalType: PhysicalType.TEXT,
|
|
123
|
-
isTextual: true,
|
|
124
|
-
supportedCollations: ['BINARY', 'NOCASE', 'RTRIM'],
|
|
125
|
-
|
|
126
|
-
validate: (v) => {
|
|
127
|
-
if (v === null) return true;
|
|
128
|
-
return typeof v === 'string';
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
parse: (v) => {
|
|
132
|
-
if (v === null) return null;
|
|
133
|
-
if (typeof v === 'string') return v;
|
|
134
|
-
if (typeof v === 'number' || typeof v === 'bigint' || typeof v === 'boolean') {
|
|
135
|
-
return String(v);
|
|
136
|
-
}
|
|
137
|
-
if (v instanceof Uint8Array) {
|
|
138
|
-
// Convert blob to hex string
|
|
139
|
-
return Array.from(v)
|
|
140
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
141
|
-
.join('');
|
|
142
|
-
}
|
|
143
|
-
throw new TypeError(`Cannot convert ${typeof v} to TEXT`);
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
compare: (a, b, collation) => {
|
|
147
|
-
if (a === null && b === null) return 0;
|
|
148
|
-
if (a === null) return -1;
|
|
149
|
-
if (b === null) return 1;
|
|
150
|
-
|
|
151
|
-
const strA = a as string;
|
|
152
|
-
const strB = b as string;
|
|
153
|
-
|
|
154
|
-
if (collation) {
|
|
155
|
-
return collation(strA, strB);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Default binary comparison
|
|
159
|
-
return strA < strB ? -1 : strA > strB ? 1 : 0;
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* BLOB type - binary data
|
|
165
|
-
*/
|
|
166
|
-
export const BLOB_TYPE: LogicalType = {
|
|
167
|
-
name: 'BLOB',
|
|
168
|
-
physicalType: PhysicalType.BLOB,
|
|
169
|
-
|
|
170
|
-
validate: (v) => {
|
|
171
|
-
if (v === null) return true;
|
|
172
|
-
return v instanceof Uint8Array;
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
parse: (v) => {
|
|
176
|
-
if (v === null) return null;
|
|
177
|
-
if (v instanceof Uint8Array) return v;
|
|
178
|
-
if (typeof v === 'string') {
|
|
179
|
-
// Check if it's a hex string (even length, all hex chars)
|
|
180
|
-
if (v.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(v) && v.length > 0) {
|
|
181
|
-
// Convert hex string to blob
|
|
182
|
-
const bytes = new Uint8Array(v.length / 2);
|
|
183
|
-
for (let i = 0; i < v.length; i += 2) {
|
|
184
|
-
bytes[i / 2] = parseInt(v.substr(i, 2), 16);
|
|
185
|
-
}
|
|
186
|
-
return bytes;
|
|
187
|
-
}
|
|
188
|
-
// For non-hex strings, convert to UTF-8 bytes
|
|
189
|
-
const encoder = new TextEncoder();
|
|
190
|
-
return encoder.encode(v);
|
|
191
|
-
}
|
|
192
|
-
if (typeof v === 'number' || typeof v === 'bigint' || typeof v === 'boolean') {
|
|
193
|
-
// Convert to string first, then to UTF-8 bytes
|
|
194
|
-
const encoder = new TextEncoder();
|
|
195
|
-
return encoder.encode(String(v));
|
|
196
|
-
}
|
|
197
|
-
throw new TypeError(`Cannot convert ${typeof v} to BLOB`);
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
compare: (a, b) => {
|
|
201
|
-
if (a === null && b === null) return 0;
|
|
202
|
-
if (a === null) return -1;
|
|
203
|
-
if (b === null) return 1;
|
|
204
|
-
|
|
205
|
-
const blobA = a as Uint8Array;
|
|
206
|
-
const blobB = b as Uint8Array;
|
|
207
|
-
|
|
208
|
-
const minLen = Math.min(blobA.length, blobB.length);
|
|
209
|
-
for (let i = 0; i < minLen; i++) {
|
|
210
|
-
if (blobA[i] !== blobB[i]) {
|
|
211
|
-
return blobA[i] < blobB[i] ? -1 : 1;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return blobA.length - blobB.length;
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* BOOLEAN type - true/false values
|
|
221
|
-
*/
|
|
222
|
-
export const BOOLEAN_TYPE: LogicalType = {
|
|
223
|
-
name: 'BOOLEAN',
|
|
224
|
-
physicalType: PhysicalType.BOOLEAN,
|
|
225
|
-
|
|
226
|
-
validate: (v) => {
|
|
227
|
-
if (v === null) return true;
|
|
228
|
-
return typeof v === 'boolean';
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
parse: (v) => {
|
|
232
|
-
if (v === null) return null;
|
|
233
|
-
if (typeof v === 'boolean') return v;
|
|
234
|
-
if (typeof v === 'number' || typeof v === 'bigint') {
|
|
235
|
-
return v !== 0;
|
|
236
|
-
}
|
|
237
|
-
if (typeof v === 'string') {
|
|
238
|
-
const lower = v.toLowerCase().trim();
|
|
239
|
-
if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on') return true;
|
|
240
|
-
if (lower === 'false' || lower === '0' || lower === 'no' || lower === 'off') return false;
|
|
241
|
-
throw new TypeError(`Cannot convert '${v}' to BOOLEAN`);
|
|
242
|
-
}
|
|
243
|
-
throw new TypeError(`Cannot convert ${typeof v} to BOOLEAN`);
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
compare: (a, b) => {
|
|
247
|
-
if (a === null && b === null) return 0;
|
|
248
|
-
if (a === null) return -1;
|
|
249
|
-
if (b === null) return 1;
|
|
250
|
-
|
|
251
|
-
const boolA = a as boolean;
|
|
252
|
-
const boolB = b as boolean;
|
|
253
|
-
|
|
254
|
-
// false < true
|
|
255
|
-
if (boolA === boolB) return 0;
|
|
256
|
-
return boolA ? 1 : -1;
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* NUMERIC type - for backward compatibility with SQLite's NUMERIC affinity
|
|
262
|
-
* Tries to store as INTEGER if possible, otherwise REAL
|
|
263
|
-
*/
|
|
264
|
-
export const NUMERIC_TYPE: LogicalType = {
|
|
265
|
-
name: 'NUMERIC',
|
|
266
|
-
physicalType: PhysicalType.REAL,
|
|
267
|
-
isNumeric: true,
|
|
268
|
-
|
|
269
|
-
validate: (v) => {
|
|
270
|
-
if (v === null) return true;
|
|
271
|
-
return typeof v === 'number' || typeof v === 'bigint';
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
parse: (v) => {
|
|
275
|
-
if (v === null) return null;
|
|
276
|
-
if (typeof v === 'number' || typeof v === 'bigint') return v;
|
|
277
|
-
if (typeof v === 'boolean') return v ? 1 : 0;
|
|
278
|
-
if (typeof v === 'string') {
|
|
279
|
-
const trimmed = v.trim();
|
|
280
|
-
if (trimmed === '') return null;
|
|
281
|
-
|
|
282
|
-
// Try integer first
|
|
283
|
-
if (/^-?\d+$/.test(trimmed)) {
|
|
284
|
-
const parsed = parseInt(trimmed, 10);
|
|
285
|
-
if (!isNaN(parsed)) return parsed;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Fall back to real
|
|
289
|
-
const parsed = parseFloat(trimmed);
|
|
290
|
-
if (isNaN(parsed)) {
|
|
291
|
-
throw new TypeError(`Cannot convert '${v}' to NUMERIC`);
|
|
292
|
-
}
|
|
293
|
-
return parsed;
|
|
294
|
-
}
|
|
295
|
-
throw new TypeError(`Cannot convert ${typeof v} to NUMERIC`);
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
compare: (a, b) => {
|
|
299
|
-
// Use REAL comparison
|
|
300
|
-
return REAL_TYPE.compare!(a, b);
|
|
301
|
-
},
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* ANY type - accepts any value without conversion
|
|
306
|
-
* Useful for dynamic data or when type is truly unknown
|
|
307
|
-
* Note: Uses NULL as physical type since it can represent any type
|
|
308
|
-
*/
|
|
309
|
-
export const ANY_TYPE: LogicalType = {
|
|
310
|
-
name: 'ANY',
|
|
311
|
-
physicalType: PhysicalType.NULL,
|
|
312
|
-
|
|
313
|
-
validate: () => true, // Accept any value
|
|
314
|
-
|
|
315
|
-
parse: (v) => v, // No conversion, store as-is
|
|
316
|
-
|
|
317
|
-
compare: (a, b) => {
|
|
318
|
-
// Follow SQLite comparison rules: NULL < NUMERIC < TEXT < BLOB
|
|
319
|
-
if (a === null && b === null) return 0;
|
|
320
|
-
if (a === null) return -1;
|
|
321
|
-
if (b === null) return 1;
|
|
322
|
-
|
|
323
|
-
// Determine storage classes following SQLite rules
|
|
324
|
-
const getStorageClass = (v: any): number => {
|
|
325
|
-
const type = typeof v;
|
|
326
|
-
if (type === 'number' || type === 'bigint' || type === 'boolean') return 1; // NUMERIC
|
|
327
|
-
if (type === 'string') return 2; // TEXT
|
|
328
|
-
if (type === 'object' && v instanceof Uint8Array) return 3; // BLOB
|
|
329
|
-
return 4; // UNKNOWN
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const classA = getStorageClass(a);
|
|
333
|
-
const classB = getStorageClass(b);
|
|
334
|
-
|
|
335
|
-
// Different storage classes: compare by class
|
|
336
|
-
if (classA !== classB) {
|
|
337
|
-
return classA < classB ? -1 : 1;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Same storage class: compare values
|
|
341
|
-
// For booleans, convert to numbers (false=0, true=1)
|
|
342
|
-
const valA = typeof a === 'boolean' ? (a ? 1 : 0) : a;
|
|
343
|
-
const valB = typeof b === 'boolean' ? (b ? 1 : 0) : b;
|
|
344
|
-
|
|
345
|
-
if (valA < valB) return -1;
|
|
346
|
-
if (valA > valB) return 1;
|
|
347
|
-
return 0;
|
|
348
|
-
},
|
|
349
|
-
};
|
|
350
|
-
|
package/src/types/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Core type system exports
|
|
2
|
-
export { PhysicalType, type LogicalType, getPhysicalType, physicalTypeName } from './logical-type.js';
|
|
3
|
-
|
|
4
|
-
// Built-in types
|
|
5
|
-
export { NULL_TYPE, INTEGER_TYPE, REAL_TYPE, TEXT_TYPE, BLOB_TYPE, BOOLEAN_TYPE, NUMERIC_TYPE, ANY_TYPE } from './builtin-types.js';
|
|
6
|
-
|
|
7
|
-
// Temporal types
|
|
8
|
-
export { DATE_TYPE, TIME_TYPE, DATETIME_TYPE, TIMESPAN_TYPE } from './temporal-types.js';
|
|
9
|
-
|
|
10
|
-
// JSON type
|
|
11
|
-
export { JSON_TYPE } from './json-type.js';
|
|
12
|
-
|
|
13
|
-
// Type registry
|
|
14
|
-
export { typeRegistry, registerType, getType, getTypeOrDefault, inferType } from './registry.js';
|
|
15
|
-
|
|
16
|
-
// Validation utilities
|
|
17
|
-
export { validateValue, parseValue, validateAndParse, isValidForType, tryParse } from './validation.js';
|
package/src/types/json-type.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { PhysicalType, type LogicalType } from './logical-type.js';
|
|
2
|
-
import { safeJsonParse } from '../func/builtins/json-helpers.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* JSON type - stores valid JSON strings
|
|
6
|
-
* Uses TEXT for physical storage but validates JSON syntax
|
|
7
|
-
* Provides deep equality comparison for JSON values
|
|
8
|
-
*/
|
|
9
|
-
export const JSON_TYPE: LogicalType = {
|
|
10
|
-
name: 'JSON',
|
|
11
|
-
physicalType: PhysicalType.TEXT,
|
|
12
|
-
|
|
13
|
-
validate: (v) => {
|
|
14
|
-
if (v === null) return true;
|
|
15
|
-
if (typeof v !== 'string') return false;
|
|
16
|
-
// Validate that it's valid JSON
|
|
17
|
-
return safeJsonParse(v) !== null;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
parse: (v) => {
|
|
21
|
-
if (v === null) return null;
|
|
22
|
-
|
|
23
|
-
// If it's already a string, validate and normalize it
|
|
24
|
-
if (typeof v === 'string') {
|
|
25
|
-
const parsed = safeJsonParse(v);
|
|
26
|
-
if (parsed === null) {
|
|
27
|
-
throw new TypeError(`Cannot convert '${v}' to JSON: invalid JSON syntax`);
|
|
28
|
-
}
|
|
29
|
-
// Normalize by re-stringifying (removes whitespace, ensures consistent format)
|
|
30
|
-
try {
|
|
31
|
-
return JSON.stringify(parsed);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
throw new TypeError(`Cannot convert to JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Convert other types to JSON
|
|
38
|
-
if (typeof v === 'number' || typeof v === 'boolean') {
|
|
39
|
-
return JSON.stringify(v);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof v === 'bigint') {
|
|
43
|
-
// BigInt can't be directly serialized to JSON, convert to number
|
|
44
|
-
return JSON.stringify(Number(v));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
throw new TypeError(`Cannot convert ${typeof v} to JSON`);
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
compare: (a, b) => {
|
|
51
|
-
// NULL handling
|
|
52
|
-
if (a === null && b === null) return 0;
|
|
53
|
-
if (a === null) return -1;
|
|
54
|
-
if (b === null) return 1;
|
|
55
|
-
|
|
56
|
-
// Both should be strings at this point
|
|
57
|
-
if (typeof a !== 'string' || typeof b !== 'string') {
|
|
58
|
-
// Fallback to string comparison
|
|
59
|
-
return String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Parse both JSON values
|
|
63
|
-
const parsedA = safeJsonParse(a);
|
|
64
|
-
const parsedB = safeJsonParse(b);
|
|
65
|
-
|
|
66
|
-
// If either is invalid JSON, fall back to string comparison
|
|
67
|
-
if (parsedA === null || parsedB === null) {
|
|
68
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Deep equality comparison
|
|
72
|
-
return deepCompareJson(parsedA, parsedB);
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// No collations for JSON type
|
|
76
|
-
supportedCollations: [],
|
|
77
|
-
|
|
78
|
-
// Metadata
|
|
79
|
-
isNumeric: false,
|
|
80
|
-
isTextual: false,
|
|
81
|
-
isTemporal: false,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Deep comparison of JSON values
|
|
86
|
-
* Returns -1, 0, or 1 for ordering
|
|
87
|
-
*/
|
|
88
|
-
function deepCompareJson(a: any, b: any): number {
|
|
89
|
-
// Same reference or both null/undefined
|
|
90
|
-
if (a === b) return 0;
|
|
91
|
-
|
|
92
|
-
// Type comparison first
|
|
93
|
-
const typeA = typeof a;
|
|
94
|
-
const typeB = typeof b;
|
|
95
|
-
|
|
96
|
-
if (typeA !== typeB) {
|
|
97
|
-
// Order: null < boolean < number < string < array < object
|
|
98
|
-
const typeOrder = {
|
|
99
|
-
'object': a === null ? 0 : Array.isArray(a) ? 4 : 5,
|
|
100
|
-
'boolean': 1,
|
|
101
|
-
'number': 2,
|
|
102
|
-
'string': 3
|
|
103
|
-
};
|
|
104
|
-
const orderA = typeOrder[typeA as keyof typeof typeOrder] ?? 6;
|
|
105
|
-
const orderB = typeOrder[typeB as keyof typeof typeOrder] ?? 6;
|
|
106
|
-
return orderA < orderB ? -1 : 1;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Same type comparison
|
|
110
|
-
if (a === null) return 0;
|
|
111
|
-
|
|
112
|
-
if (typeof a === 'boolean' || typeof a === 'number' || typeof a === 'string') {
|
|
113
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
117
|
-
// Compare arrays element by element
|
|
118
|
-
const minLen = Math.min(a.length, b.length);
|
|
119
|
-
for (let i = 0; i < minLen; i++) {
|
|
120
|
-
const cmp = deepCompareJson(a[i], b[i]);
|
|
121
|
-
if (cmp !== 0) return cmp;
|
|
122
|
-
}
|
|
123
|
-
// If all elements are equal, shorter array comes first
|
|
124
|
-
return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (typeof a === 'object' && typeof b === 'object') {
|
|
128
|
-
// Compare objects by sorted keys
|
|
129
|
-
const keysA = Object.keys(a).sort();
|
|
130
|
-
const keysB = Object.keys(b).sort();
|
|
131
|
-
|
|
132
|
-
// Compare key sets first
|
|
133
|
-
const minKeys = Math.min(keysA.length, keysB.length);
|
|
134
|
-
for (let i = 0; i < minKeys; i++) {
|
|
135
|
-
if (keysA[i] < keysB[i]) return -1;
|
|
136
|
-
if (keysA[i] > keysB[i]) return 1;
|
|
137
|
-
}
|
|
138
|
-
if (keysA.length < keysB.length) return -1;
|
|
139
|
-
if (keysA.length > keysB.length) return 1;
|
|
140
|
-
|
|
141
|
-
// Keys are the same, compare values
|
|
142
|
-
for (const key of keysA) {
|
|
143
|
-
const cmp = deepCompareJson(a[key], b[key]);
|
|
144
|
-
if (cmp !== 0) return cmp;
|
|
145
|
-
}
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Fallback
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { SqlValue } from '../common/types.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Function type for SQLite collation functions.
|
|
5
|
-
* Takes two strings and returns a comparison result (-1, 0, 1)
|
|
6
|
-
*/
|
|
7
|
-
export type CollationFunction = (a: string, b: string) => number;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Physical types represent how values are stored in memory and on disk.
|
|
11
|
-
* These are the actual runtime representations.
|
|
12
|
-
*/
|
|
13
|
-
export enum PhysicalType {
|
|
14
|
-
NULL = 0,
|
|
15
|
-
INTEGER = 1, // number | bigint
|
|
16
|
-
REAL = 2, // number (floating point)
|
|
17
|
-
TEXT = 3, // string
|
|
18
|
-
BLOB = 4, // Uint8Array
|
|
19
|
-
BOOLEAN = 5, // boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Logical types define the semantics and behavior of values.
|
|
24
|
-
* They specify validation, comparison, and conversion rules.
|
|
25
|
-
*/
|
|
26
|
-
export interface LogicalType {
|
|
27
|
-
// Identity
|
|
28
|
-
/** Type name (e.g., "DATE", "INTEGER", "TEXT") */
|
|
29
|
-
name: string;
|
|
30
|
-
/** Physical storage representation */
|
|
31
|
-
physicalType: PhysicalType;
|
|
32
|
-
|
|
33
|
-
// Validation
|
|
34
|
-
/** Check if value is valid for this type */
|
|
35
|
-
validate?(value: SqlValue): boolean;
|
|
36
|
-
/** Convert/normalize value to canonical form */
|
|
37
|
-
parse?(value: SqlValue): SqlValue;
|
|
38
|
-
|
|
39
|
-
// Comparison
|
|
40
|
-
/** Type-specific comparison function */
|
|
41
|
-
compare?(a: SqlValue, b: SqlValue, collation?: CollationFunction): number;
|
|
42
|
-
/** Which collations apply to this type */
|
|
43
|
-
supportedCollations?: readonly string[];
|
|
44
|
-
|
|
45
|
-
// Serialization
|
|
46
|
-
/** Convert for storage/export */
|
|
47
|
-
serialize?(value: SqlValue): SqlValue;
|
|
48
|
-
/** Convert from storage */
|
|
49
|
-
deserialize?(value: SqlValue): SqlValue;
|
|
50
|
-
|
|
51
|
-
// Metadata
|
|
52
|
-
/** Is this a numeric type? */
|
|
53
|
-
isNumeric?: boolean;
|
|
54
|
-
/** Is this a textual type? */
|
|
55
|
-
isTextual?: boolean;
|
|
56
|
-
/** Is this a temporal type? */
|
|
57
|
-
isTemporal?: boolean;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Get the physical type of a SqlValue at runtime.
|
|
62
|
-
* This is used for values that don't have an associated logical type.
|
|
63
|
-
*/
|
|
64
|
-
export function getPhysicalType(value: SqlValue): PhysicalType {
|
|
65
|
-
if (value === null) return PhysicalType.NULL;
|
|
66
|
-
if (typeof value === 'number') {
|
|
67
|
-
return Number.isInteger(value) ? PhysicalType.INTEGER : PhysicalType.REAL;
|
|
68
|
-
}
|
|
69
|
-
if (typeof value === 'bigint') return PhysicalType.INTEGER;
|
|
70
|
-
if (typeof value === 'string') return PhysicalType.TEXT;
|
|
71
|
-
if (typeof value === 'boolean') return PhysicalType.BOOLEAN;
|
|
72
|
-
if (value instanceof Uint8Array) return PhysicalType.BLOB;
|
|
73
|
-
return PhysicalType.NULL;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get a human-readable name for a physical type code.
|
|
78
|
-
* Useful for error messages and debugging.
|
|
79
|
-
*/
|
|
80
|
-
export function physicalTypeName(physicalType: PhysicalType): string {
|
|
81
|
-
switch (physicalType) {
|
|
82
|
-
case PhysicalType.NULL: return 'NULL';
|
|
83
|
-
case PhysicalType.INTEGER: return 'INTEGER';
|
|
84
|
-
case PhysicalType.REAL: return 'REAL';
|
|
85
|
-
case PhysicalType.TEXT: return 'TEXT';
|
|
86
|
-
case PhysicalType.BLOB: return 'BLOB';
|
|
87
|
-
case PhysicalType.BOOLEAN: return 'BOOLEAN';
|
|
88
|
-
default: return 'UNKNOWN';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|