@quereus/quereus 4.11.0 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/common/type-inference.d.ts +12 -6
- package/dist/src/common/type-inference.d.ts.map +1 -1
- package/dist/src/common/type-inference.js +12 -24
- package/dist/src/common/type-inference.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +7 -5
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +4 -3
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +4 -3
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.d.ts +1 -3
- package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.js +1 -11
- package/dist/src/core/database-materialized-views-analysis.js.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.js +12 -10
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +13 -2
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/derived-row-validator.d.ts.map +1 -1
- package/dist/src/core/derived-row-validator.js +14 -2
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/param.d.ts +9 -0
- package/dist/src/core/param.d.ts.map +1 -1
- package/dist/src/core/param.js +21 -1
- package/dist/src/core/param.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +38 -15
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
- package/dist/src/func/builtins/aggregate.js +7 -2
- package/dist/src/func/builtins/aggregate.js.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.js +27 -11
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +8 -3
- package/dist/src/func/builtins/datetime.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +9 -29
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
- package/dist/src/func/builtins/json-tvf.js +14 -7
- package/dist/src/func/builtins/json-tvf.js.map +1 -1
- package/dist/src/func/builtins/return-types.d.ts +29 -0
- package/dist/src/func/builtins/return-types.d.ts.map +1 -1
- package/dist/src/func/builtins/return-types.js +4 -1
- package/dist/src/func/builtins/return-types.js.map +1 -1
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +22 -67
- package/dist/src/func/builtins/scalar.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +26 -16
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +5 -3
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/visitor.d.ts +16 -0
- package/dist/src/parser/visitor.d.ts.map +1 -1
- package/dist/src/parser/visitor.js +16 -0
- package/dist/src/parser/visitor.js.map +1 -1
- package/dist/src/planner/analysis/assertion-plan.d.ts +33 -0
- package/dist/src/planner/analysis/assertion-plan.d.ts.map +1 -0
- package/dist/src/planner/analysis/assertion-plan.js +39 -0
- package/dist/src/planner/analysis/assertion-plan.js.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts +55 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.js +57 -0
- package/dist/src/planner/analysis/binary-operator-class.js.map +1 -0
- package/dist/src/planner/analysis/binding-extractor.d.ts +9 -3
- package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/binding-extractor.js +11 -16
- package/dist/src/planner/analysis/binding-extractor.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +19 -6
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/check-extraction.d.ts +1 -7
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
- package/dist/src/planner/analysis/check-extraction.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +17 -0
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +17 -5
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +18 -18
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts +11 -7
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +11 -7
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +1 -1
- package/dist/src/planner/analysis/equi-correlation.js +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.js +0 -2
- package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
- package/dist/src/planner/analysis/key-filter.d.ts.map +1 -1
- package/dist/src/planner/analysis/key-filter.js +2 -3
- package/dist/src/planner/analysis/key-filter.js.map +1 -1
- package/dist/src/planner/analysis/relation-key.d.ts +104 -0
- package/dist/src/planner/analysis/relation-key.d.ts.map +1 -0
- package/dist/src/planner/analysis/relation-key.js +121 -0
- package/dist/src/planner/analysis/relation-key.js.map +1 -0
- package/dist/src/planner/analysis/scalar-param-usage.d.ts.map +1 -1
- package/dist/src/planner/analysis/scalar-param-usage.js +12 -4
- package/dist/src/planner/analysis/scalar-param-usage.js.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.d.ts +9 -3
- package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.js +22 -8
- package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +31 -23
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/analyze.d.ts.map +1 -1
- package/dist/src/planner/building/analyze.js +21 -0
- package/dist/src/planner/building/analyze.js.map +1 -1
- package/dist/src/planner/building/block.d.ts.map +1 -1
- package/dist/src/planner/building/block.js +222 -82
- package/dist/src/planner/building/block.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +5 -3
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/delete.js +1 -1
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +11 -3
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts +16 -6
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +43 -20
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/generated-column-scope.d.ts +58 -0
- package/dist/src/planner/building/generated-column-scope.d.ts.map +1 -0
- package/dist/src/planner/building/generated-column-scope.js +117 -0
- package/dist/src/planner/building/generated-column-scope.js.map +1 -0
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +20 -28
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +73 -132
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +405 -81
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +37 -8
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +8 -9
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-ordinal.d.ts +6 -0
- package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
- package/dist/src/planner/building/select-ordinal.js +1 -1
- package/dist/src/planner/building/select-ordinal.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts +2 -2
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +82 -101
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +78 -33
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +14 -8
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +329 -14
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts +6 -0
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +52 -3
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
- package/dist/src/planner/cache/correlation-detector.js +44 -17
- package/dist/src/planner/cache/correlation-detector.js.map +1 -1
- package/dist/src/planner/framework/physical-utils.d.ts +6 -0
- package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
- package/dist/src/planner/framework/physical-utils.js +6 -0
- package/dist/src/planner/framework/physical-utils.js.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.d.ts +123 -0
- package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +362 -5
- package/dist/src/planner/mutation/lens-enforcement.js.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.d.ts +15 -11
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.js +5 -0
- package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.js +7 -0
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +16 -0
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
- package/dist/src/planner/nodes/pragma.js +5 -2
- package/dist/src/planner/nodes/pragma.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +9 -1
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +117 -91
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sequence-node.d.ts +50 -0
- package/dist/src/planner/nodes/sequence-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/sequence-node.js +96 -0
- package/dist/src/planner/nodes/sequence-node.js.map +1 -0
- package/dist/src/planner/nodes/values-node.d.ts +8 -0
- package/dist/src/planner/nodes/values-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/values-node.js +29 -6
- package/dist/src/planner/nodes/values-node.js.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts +43 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.js +27 -6
- package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +33 -4
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +80 -36
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +38 -1
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.js +8 -3
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +18 -12
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +4 -3
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.js +6 -0
- package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
- package/dist/src/planner/scopes/param.d.ts.map +1 -1
- package/dist/src/planner/scopes/param.js +10 -5
- package/dist/src/planner/scopes/param.js.map +1 -1
- package/dist/src/planner/util/ind-utils.d.ts +25 -8
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +53 -10
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +7 -7
- package/dist/src/planner/util/key-utils.js +9 -9
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/runtime/delta-executor.d.ts.map +1 -1
- package/dist/src/runtime/delta-executor.js +7 -2
- package/dist/src/runtime/delta-executor.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +50 -15
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +2 -43
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.js +2 -53
- package/dist/src/runtime/emit/alter-schema-event.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +59 -24
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
- package/dist/src/runtime/emit/analyze.js +7 -0
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.js +2 -3
- package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts +5 -0
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +22 -22
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/block.d.ts.map +1 -1
- package/dist/src/runtime/emit/block.js +9 -3
- package/dist/src/runtime/emit/block.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +5 -6
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-assertion.js +71 -70
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-index.js +8 -3
- package/dist/src/runtime/emit/create-index.js.map +1 -1
- package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-table.js +20 -10
- package/dist/src/runtime/emit/create-table.js.map +1 -1
- package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-view.js +51 -44
- package/dist/src/runtime/emit/create-view.js.map +1 -1
- package/dist/src/runtime/emit/ddl-event-scope.d.ts +71 -0
- package/dist/src/runtime/emit/ddl-event-scope.d.ts.map +1 -0
- package/dist/src/runtime/emit/ddl-event-scope.js +80 -0
- package/dist/src/runtime/emit/ddl-event-scope.js.map +1 -0
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +23 -23
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +23 -17
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +7 -2
- package/dist/src/runtime/emit/drop-index.js.map +1 -1
- package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-table.js +16 -10
- package/dist/src/runtime/emit/drop-table.js.map +1 -1
- package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-view.js +50 -43
- package/dist/src/runtime/emit/drop-view.js.map +1 -1
- package/dist/src/runtime/emit/insert.d.ts.map +1 -1
- package/dist/src/runtime/emit/insert.js +2 -1
- package/dist/src/runtime/emit/insert.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view.js +87 -67
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts +8 -0
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +128 -25
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/sequence.d.ts +17 -0
- package/dist/src/runtime/emit/sequence.d.ts.map +1 -0
- package/dist/src/runtime/emit/sequence.js +40 -0
- package/dist/src/runtime/emit/sequence.js.map +1 -0
- package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-object-tags.js +40 -32
- package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.js +3 -2
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/update.js +3 -3
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
- package/dist/src/runtime/emit/view-mutation.js +45 -3
- package/dist/src/runtime/emit/view-mutation.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +9 -10
- package/dist/src/runtime/foreign-key-actions.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +3 -2
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/row-constraints.d.ts +14 -8
- package/dist/src/runtime/row-constraints.d.ts.map +1 -1
- package/dist/src/runtime/row-constraints.js +41 -15
- package/dist/src/runtime/row-constraints.js.map +1 -1
- package/dist/src/runtime/strict-representation.d.ts +11 -6
- package/dist/src/runtime/strict-representation.d.ts.map +1 -1
- package/dist/src/runtime/strict-representation.js +1 -44
- package/dist/src/runtime/strict-representation.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +25 -2
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/catalog-rendering.d.ts +38 -0
- package/dist/src/schema/catalog-rendering.d.ts.map +1 -0
- package/dist/src/schema/catalog-rendering.js +171 -0
- package/dist/src/schema/catalog-rendering.js.map +1 -0
- package/dist/src/schema/catalog.d.ts +69 -3
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +124 -19
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/column-source-resolver.d.ts +9 -5
- package/dist/src/schema/column-source-resolver.d.ts.map +1 -1
- package/dist/src/schema/column-source-resolver.js +9 -5
- package/dist/src/schema/column-source-resolver.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts +13 -10
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +45 -17
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/declared-schema-manager.d.ts +50 -0
- package/dist/src/schema/declared-schema-manager.d.ts.map +1 -1
- package/dist/src/schema/declared-schema-manager.js +52 -0
- package/dist/src/schema/declared-schema-manager.js.map +1 -1
- package/dist/src/schema/expr-scope/frame.d.ts +65 -0
- package/dist/src/schema/expr-scope/frame.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/frame.js +104 -0
- package/dist/src/schema/expr-scope/frame.js.map +1 -0
- package/dist/src/schema/expr-scope/walk.d.ts +40 -0
- package/dist/src/schema/expr-scope/walk.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/walk.js +260 -0
- package/dist/src/schema/expr-scope/walk.js.map +1 -0
- package/dist/src/schema/generated-column-refs.d.ts +41 -0
- package/dist/src/schema/generated-column-refs.d.ts.map +1 -0
- package/dist/src/schema/generated-column-refs.js +124 -0
- package/dist/src/schema/generated-column-refs.js.map +1 -0
- package/dist/src/schema/lens-ack.d.ts.map +1 -1
- package/dist/src/schema/lens-ack.js +5 -2
- package/dist/src/schema/lens-ack.js.map +1 -1
- package/dist/src/schema/lens-compiler.d.ts.map +1 -1
- package/dist/src/schema/lens-compiler.js +9 -1
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts +7 -2
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +105 -11
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/lens.d.ts +12 -0
- package/dist/src/schema/lens.d.ts.map +1 -1
- package/dist/src/schema/lens.js +10 -0
- package/dist/src/schema/lens.js.map +1 -1
- package/dist/src/schema/manager.d.ts +35 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +125 -26
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.d.ts +16 -10
- package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.js +30 -213
- package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +4 -3
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +4 -3
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +54 -6
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +108 -42
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/schema-hasher.d.ts +12 -0
- package/dist/src/schema/schema-hasher.d.ts.map +1 -1
- package/dist/src/schema/schema-hasher.js +28 -10
- package/dist/src/schema/schema-hasher.js.map +1 -1
- package/dist/src/schema/table.d.ts +74 -19
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +133 -71
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/types/comparison-coercion.d.ts +5 -1
- package/dist/src/types/comparison-coercion.d.ts.map +1 -1
- package/dist/src/types/comparison-coercion.js +21 -5
- package/dist/src/types/comparison-coercion.js.map +1 -1
- package/dist/src/types/representation.d.ts +65 -0
- package/dist/src/types/representation.d.ts.map +1 -0
- package/dist/src/types/representation.js +63 -0
- package/dist/src/types/representation.js.map +1 -0
- package/dist/src/types/validation.d.ts +76 -22
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +110 -31
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +10 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +16 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/capabilities.d.ts +72 -4
- package/dist/src/vtab/capabilities.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +17 -13
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/module.d.ts +13 -7
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/src/planner/nodes/array-index-node.d.ts +0 -22
- package/dist/src/planner/nodes/array-index-node.d.ts.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js +0 -41
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/runtime/emit/array-index.d.ts +0 -5
- package/dist/src/runtime/emit/array-index.d.ts.map +0 -1
- package/dist/src/runtime/emit/array-index.js +0 -22
- package/dist/src/runtime/emit/array-index.js.map +0 -1
|
@@ -89,7 +89,7 @@ function duplicateDeclaredNameError(dup, schemaName) {
|
|
|
89
89
|
return new QuereusError(`'${name}' is declared as both a ${priorKind} and a ${kind} in schema '${schemaName}'`, StatusCode.ERROR);
|
|
90
90
|
}
|
|
91
91
|
if (kind === 'index') {
|
|
92
|
-
// Pinned wording — documented in docs/sql-
|
|
92
|
+
// Pinned wording — documented in docs/sql-vtab.md § 6.3 and SCH-001.
|
|
93
93
|
return new QuereusError(`Index '${name}' is declared more than once in schema '${schemaName}'`
|
|
94
94
|
+ ` (on '${firstTable}' and '${secondTable}') — index names are unique per schema`, StatusCode.ERROR);
|
|
95
95
|
}
|
|
@@ -386,7 +386,7 @@ defaultCollation = 'BINARY') {
|
|
|
386
386
|
// two names are identical.
|
|
387
387
|
const dropName = matchedActual.name.toLowerCase() !== name ? name : matchedActual.name.toLowerCase();
|
|
388
388
|
dropSet.add(dropName);
|
|
389
|
-
diff.tablesToCreate.push(
|
|
389
|
+
diff.tablesToCreate.push(freshTableCreate(name, tableStmt, declaredMaterializedViews, targetSchemaName, defaultVtabModule, defaultVtabArgs));
|
|
390
390
|
diff.maintainedModuleMigrations.push({
|
|
391
391
|
name: tableStmt.table.name,
|
|
392
392
|
fromModule: alterDiff.maintainedModuleMigration.fromModule,
|
|
@@ -415,7 +415,7 @@ defaultCollation = 'BINARY') {
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
else {
|
|
418
|
-
diff.tablesToCreate.push(
|
|
418
|
+
diff.tablesToCreate.push(freshTableCreate(name, tableStmt, declaredMaterializedViews, targetSchemaName, defaultVtabModule, defaultVtabArgs));
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
// Tables: drops (skip those consumed by a rename). The module-move drops added
|
|
@@ -459,7 +459,7 @@ defaultCollation = 'BINARY') {
|
|
|
459
459
|
for (const [name, declaredView] of declaredViews) {
|
|
460
460
|
const matchedActual = viewRenames.pairs.get(name);
|
|
461
461
|
if (!matchedActual) {
|
|
462
|
-
diff.viewsToCreate.push(
|
|
462
|
+
diff.viewsToCreate.push(viewCreate(applyViewSchemaDefault(declaredView.viewStmt, targetSchemaName)));
|
|
463
463
|
continue;
|
|
464
464
|
}
|
|
465
465
|
const stmt = declaredView.viewStmt;
|
|
@@ -478,7 +478,7 @@ defaultCollation = 'BINARY') {
|
|
|
478
478
|
}
|
|
479
479
|
if (definitionDrifted) {
|
|
480
480
|
diff.viewsToDrop.push(matchedActual.name);
|
|
481
|
-
diff.viewsToCreate.push(
|
|
481
|
+
diff.viewsToCreate.push(viewCreate(applyViewSchemaDefault(stmt, targetSchemaName)));
|
|
482
482
|
viewRecreates++;
|
|
483
483
|
continue;
|
|
484
484
|
}
|
|
@@ -486,7 +486,7 @@ defaultCollation = 'BINARY') {
|
|
|
486
486
|
// Hinted rename, definition unchanged → drop(old) + recreate(declared),
|
|
487
487
|
// rendered with in-diff column renames inverse-applied (NEW→OLD).
|
|
488
488
|
diff.viewsToDrop.push(matchedActual.name);
|
|
489
|
-
diff.viewsToCreate.push(
|
|
489
|
+
diff.viewsToCreate.push(viewCreate(applyViewSchemaDefault(columnReconciledViewStmt(stmt, columnRenamesByTable, targetSchemaName, resolveDeclaredColumn), targetSchemaName)));
|
|
490
490
|
viewRecreates++;
|
|
491
491
|
continue;
|
|
492
492
|
}
|
|
@@ -531,7 +531,7 @@ defaultCollation = 'BINARY') {
|
|
|
531
531
|
const matchedActual = indexRenames.pairs.get(name);
|
|
532
532
|
if (!matchedActual) {
|
|
533
533
|
const effectiveStmt = applyIndexDefaults(declaredIndex.indexStmt, targetSchemaName);
|
|
534
|
-
diff.indexesToCreate.push(
|
|
534
|
+
diff.indexesToCreate.push(indexCreate(effectiveStmt));
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
537
537
|
// Body comparison (canonical: name / tags excluded; per-column collation
|
|
@@ -559,7 +559,7 @@ defaultCollation = 'BINARY') {
|
|
|
559
559
|
if (declaredBody !== matchedActual.definition) {
|
|
560
560
|
diff.indexesToDrop.push(matchedActual.name);
|
|
561
561
|
const effectiveStmt = applyIndexDefaults(declaredIndex.indexStmt, targetSchemaName);
|
|
562
|
-
diff.indexesToCreate.push(
|
|
562
|
+
diff.indexesToCreate.push(indexCreate(effectiveStmt));
|
|
563
563
|
indexRecreates++;
|
|
564
564
|
continue;
|
|
565
565
|
}
|
|
@@ -568,7 +568,7 @@ defaultCollation = 'BINARY') {
|
|
|
568
568
|
// rendered with in-diff column renames inverse-applied (NEW→OLD).
|
|
569
569
|
diff.indexesToDrop.push(matchedActual.name);
|
|
570
570
|
const reconciledStmt = columnReconciledIndexStmt(declaredIndex.indexStmt, indexColRenames, columnRenamesByTable, targetSchemaName);
|
|
571
|
-
diff.indexesToCreate.push(
|
|
571
|
+
diff.indexesToCreate.push(indexCreate(applyIndexDefaults(reconciledStmt, targetSchemaName)));
|
|
572
572
|
indexRecreates++;
|
|
573
573
|
continue;
|
|
574
574
|
}
|
|
@@ -666,7 +666,7 @@ defaultCollation = 'BINARY') {
|
|
|
666
666
|
// `generateMigrationDDL`), then recreate from the declaration.
|
|
667
667
|
if (matchedActual)
|
|
668
668
|
diff.assertionsToDrop.push(matchedActual.name);
|
|
669
|
-
diff.assertionsToCreate.push(
|
|
669
|
+
diff.assertionsToCreate.push(assertionCreate(applyAssertionSchemaDefault(declaredAssertion.assertionStmt, targetSchemaName)));
|
|
670
670
|
}
|
|
671
671
|
for (const [name] of actualAssertions) {
|
|
672
672
|
if (!declaredAssertions.has(name)) {
|
|
@@ -817,21 +817,43 @@ function enforceRequireHint(kind, creates, drops) {
|
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
819
|
/**
|
|
820
|
-
*
|
|
820
|
+
* Builds the fresh-create step for a declared table — shared by the create branch
|
|
821
821
|
* and the destructive backing-module move's recreate, so both re-materialize a
|
|
822
822
|
* maintained body into the declared module through one renderer. A maintained
|
|
823
823
|
* table declared via the `materialized view` sugar renders that sugar (its
|
|
824
824
|
* column-less normalized table form has no parseable `create table` DDL); a
|
|
825
825
|
* declared-shape maintained table and a plain table render the `create table …`
|
|
826
826
|
* form (carrying any `maintained as` clause).
|
|
827
|
+
*
|
|
828
|
+
* The returned {@link MigrationCreate} pairs the rendered text with the SAME
|
|
829
|
+
* post-qualification statement it was rendered from, so `apply schema` executes
|
|
830
|
+
* exactly what `diff schema` previews.
|
|
827
831
|
*/
|
|
828
|
-
function
|
|
832
|
+
function freshTableCreate(name, tableStmt, declaredMaterializedViews, targetSchemaName, defaultVtabModule, defaultVtabArgs) {
|
|
829
833
|
const declaredMv = declaredMaterializedViews.get(name);
|
|
830
834
|
if (declaredMv) {
|
|
831
|
-
|
|
835
|
+
const mvStmt = applyViewSchemaDefault(declaredMv.viewStmt, targetSchemaName);
|
|
836
|
+
return { sql: createMaterializedViewToString(mvStmt), ast: mvStmt };
|
|
832
837
|
}
|
|
833
838
|
const effectiveStmt = applyTableDefaults(tableStmt, targetSchemaName, defaultVtabModule, defaultVtabArgs);
|
|
834
|
-
return createTableToString(effectiveStmt);
|
|
839
|
+
return { sql: createTableToString(effectiveStmt), ast: effectiveStmt };
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Pairs a view create's rendered DDL with the exact (already schema-qualified,
|
|
843
|
+
* already rename-reconciled) statement it was rendered from. Taking one statement
|
|
844
|
+
* and rendering it here — rather than accepting a pre-rendered string — is what
|
|
845
|
+
* makes text/AST disagreement unrepresentable.
|
|
846
|
+
*/
|
|
847
|
+
function viewCreate(stmt) {
|
|
848
|
+
return { sql: createViewToString(stmt), ast: stmt };
|
|
849
|
+
}
|
|
850
|
+
/** The index analogue of {@link viewCreate}. */
|
|
851
|
+
function indexCreate(stmt) {
|
|
852
|
+
return { sql: createIndexToString(stmt), ast: stmt };
|
|
853
|
+
}
|
|
854
|
+
/** The assertion analogue of {@link viewCreate}. */
|
|
855
|
+
function assertionCreate(stmt) {
|
|
856
|
+
return { sql: createAssertionToString(stmt), ast: stmt };
|
|
835
857
|
}
|
|
836
858
|
/**
|
|
837
859
|
* Qualifies a view / materialized-view create statement's own name with the
|
|
@@ -2227,6 +2249,12 @@ function computeColumnAttributeChange(declared, actual, defaultCollation) {
|
|
|
2227
2249
|
change.defaultValue = null;
|
|
2228
2250
|
any = true;
|
|
2229
2251
|
}
|
|
2252
|
+
// The retype refuses to carry an unconvertible existing default across; when this
|
|
2253
|
+
// migration replaces that default anyway, clear it ahead of the retype. See
|
|
2254
|
+
// `dropStaleDefaultFirst`.
|
|
2255
|
+
if (change.dataType !== undefined && change.defaultValue !== undefined && actualDefault !== null) {
|
|
2256
|
+
change.dropStaleDefaultFirst = true;
|
|
2257
|
+
}
|
|
2230
2258
|
// Collation — declared COLLATE (default BINARY) vs actual, case-insensitive.
|
|
2231
2259
|
// Absent and BINARY are equal, so a column that never mentions COLLATE never
|
|
2232
2260
|
// churns a diff against an actual BINARY column.
|
|
@@ -2284,7 +2312,13 @@ function pkSequencesEqual(declared, actual) {
|
|
|
2284
2312
|
return true;
|
|
2285
2313
|
}
|
|
2286
2314
|
/**
|
|
2287
|
-
* Serializes a schema diff to JSON string
|
|
2315
|
+
* Serializes a schema diff to JSON string.
|
|
2316
|
+
*
|
|
2317
|
+
* NOTE: the four create buckets serialize as `{ sql, ast }` objects (see
|
|
2318
|
+
* {@link MigrationCreate}), so the output embeds a full statement AST per create
|
|
2319
|
+
* and is far more verbose than the old bare-string form. No caller in the repo
|
|
2320
|
+
* consumes this today; a caller that only wants the DDL should read `.sql` (or
|
|
2321
|
+
* call {@link generateMigrationDDL}) rather than this whole-diff dump.
|
|
2288
2322
|
*/
|
|
2289
2323
|
export function serializeSchemaDiff(diff) {
|
|
2290
2324
|
return JSON.stringify(diff, null, 2);
|
|
@@ -2344,11 +2378,30 @@ function comparisonDomainAlters(quotedTable, quotedCol, change) {
|
|
|
2344
2378
|
: [...retype, ...recollate];
|
|
2345
2379
|
}
|
|
2346
2380
|
/**
|
|
2347
|
-
* Generates migration DDL statements from a schema diff
|
|
2381
|
+
* Generates migration DDL statements from a schema diff.
|
|
2382
|
+
*
|
|
2383
|
+
* Thin wrapper over {@link generateMigrationPlan} — the single ordering authority.
|
|
2384
|
+
* `diff schema` previews exactly this text, and `apply schema` executes the plan
|
|
2385
|
+
* these strings come from, so the two can never disagree.
|
|
2348
2386
|
*/
|
|
2349
2387
|
export function generateMigrationDDL(diff, schemaName) {
|
|
2388
|
+
return generateMigrationPlan(diff, schemaName).map(s => s.sql);
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Builds the ordered migration plan for a schema diff.
|
|
2392
|
+
*
|
|
2393
|
+
* Every step carries its `sql` (the preview text, and the text an execution error
|
|
2394
|
+
* names). Steps built from a statement AST — the four create buckets and the
|
|
2395
|
+
* `set maintained as` re-attach — also carry that AST, so `apply schema` can run
|
|
2396
|
+
* them without re-lexing the text this function just produced. The remaining steps
|
|
2397
|
+
* are short template-built strings (renames, drops, column/constraint alters,
|
|
2398
|
+
* `SET TAGS`) and stay text-only.
|
|
2399
|
+
*/
|
|
2400
|
+
export function generateMigrationPlan(diff, schemaName) {
|
|
2350
2401
|
const statements = [];
|
|
2351
2402
|
const schemaPrefix = (schemaName && schemaName !== 'main') ? `${quoteIdentifier(schemaName)}.` : '';
|
|
2403
|
+
/** Appends a template-built step — text-only, so the apply path parses it as before. */
|
|
2404
|
+
const pushText = (sql) => { statements.push({ sql }); };
|
|
2352
2405
|
// Renames first — they free old names for subsequent creates and re-target
|
|
2353
2406
|
// dependents (handled inside ALTER TABLE ... RENAME by the rename rewriter).
|
|
2354
2407
|
// Only tables have a rename primitive. The other RenameOp kinds are metadata
|
|
@@ -2359,13 +2412,13 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2359
2412
|
// the table-alter channel (RENAME CONSTRAINT below).
|
|
2360
2413
|
for (const r of diff.renames) {
|
|
2361
2414
|
if (r.kind === 'table') {
|
|
2362
|
-
|
|
2415
|
+
pushText(`ALTER TABLE ${schemaPrefix}${quoteIdentifier(r.oldName)} RENAME TO ${quoteIdentifier(r.newName)}`);
|
|
2363
2416
|
}
|
|
2364
2417
|
// Non-table rename ops emit no DDL here — see the note above.
|
|
2365
2418
|
}
|
|
2366
2419
|
// Drop assertions first (they may reference tables)
|
|
2367
2420
|
for (const name of diff.assertionsToDrop) {
|
|
2368
|
-
|
|
2421
|
+
pushText(`DROP ASSERTION IF EXISTS ${schemaPrefix}${quoteIdentifier(name)}`);
|
|
2369
2422
|
}
|
|
2370
2423
|
// Detach maintained tables (`drop maintained`) EARLY — where MV drops ran
|
|
2371
2424
|
// before — so a detach precedes any column op on that table AND any drop of its
|
|
@@ -2374,18 +2427,18 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2374
2427
|
// flip's cross-table detach-v2 / attach-v1 pair falls out of this ordering.
|
|
2375
2428
|
for (const alter of diff.tablesToAlter) {
|
|
2376
2429
|
if (alter.dropMaintained) {
|
|
2377
|
-
|
|
2430
|
+
pushText(`ALTER TABLE ${schemaPrefix}${quoteIdentifier(alter.tableName)} DROP MAINTAINED`);
|
|
2378
2431
|
}
|
|
2379
2432
|
}
|
|
2380
2433
|
// Drop items (reverse order)
|
|
2381
2434
|
for (const tableName of diff.tablesToDrop) {
|
|
2382
|
-
|
|
2435
|
+
pushText(`DROP TABLE IF EXISTS ${schemaPrefix}${quoteIdentifier(tableName)}`);
|
|
2383
2436
|
}
|
|
2384
2437
|
for (const viewName of diff.viewsToDrop) {
|
|
2385
|
-
|
|
2438
|
+
pushText(`DROP VIEW IF EXISTS ${schemaPrefix}${quoteIdentifier(viewName)}`);
|
|
2386
2439
|
}
|
|
2387
2440
|
for (const indexName of diff.indexesToDrop) {
|
|
2388
|
-
|
|
2441
|
+
pushText(`DROP INDEX IF EXISTS ${schemaPrefix}${quoteIdentifier(indexName)}`);
|
|
2389
2442
|
}
|
|
2390
2443
|
// Create new items. A fresh maintained table rides `tablesToCreate` (rendered
|
|
2391
2444
|
// as the `create materialized view` sugar) and re-materializes as part of its
|
|
@@ -2401,7 +2454,9 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2401
2454
|
// → ADD COLUMN
|
|
2402
2455
|
// → ALTER COLUMN (comparison domain, then default, then nullability — so SET
|
|
2403
2456
|
// NOT NULL can rely on an already-populated DEFAULT for backfill; the
|
|
2404
|
-
// type/collation pair orders internally, see comparisonDomainAlters
|
|
2457
|
+
// type/collation pair orders internally, see comparisonDomainAlters; a
|
|
2458
|
+
// retype whose replaced default would veto it is preceded by a DROP DEFAULT,
|
|
2459
|
+
// see dropStaleDefaultFirst)
|
|
2405
2460
|
// → RENAME CONSTRAINT, then DROP CONSTRAINT (free / remove a name before any
|
|
2406
2461
|
// re-add; a UNIQUE drop precedes the PK change so it can't strand a PK dep)
|
|
2407
2462
|
// → ALTER PRIMARY KEY
|
|
@@ -2410,26 +2465,35 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2410
2465
|
for (const alter of diff.tablesToAlter) {
|
|
2411
2466
|
const quotedTable = `${schemaPrefix}${quoteIdentifier(alter.tableName)}`;
|
|
2412
2467
|
for (const r of alter.columnsToRename) {
|
|
2413
|
-
|
|
2468
|
+
pushText(`ALTER TABLE ${quotedTable} RENAME COLUMN ${quoteIdentifier(r.oldName)} TO ${quoteIdentifier(r.newName)}`);
|
|
2414
2469
|
}
|
|
2415
2470
|
for (const colDef of alter.columnsToAdd) {
|
|
2416
|
-
|
|
2471
|
+
pushText(`ALTER TABLE ${quotedTable} ADD COLUMN ${colDef}`);
|
|
2417
2472
|
}
|
|
2418
2473
|
for (const colAlter of alter.columnsToAlter) {
|
|
2419
2474
|
const quotedCol = quoteIdentifier(colAlter.columnName);
|
|
2475
|
+
// A default the retype would choke on and this migration replaces anyway is
|
|
2476
|
+
// cleared BEFORE the comparison-domain phase (see `dropStaleDefaultFirst`).
|
|
2477
|
+
if (colAlter.dropStaleDefaultFirst) {
|
|
2478
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedCol} DROP DEFAULT`);
|
|
2479
|
+
}
|
|
2420
2480
|
// SET DATA TYPE / SET COLLATE lead the per-column phase (both are
|
|
2421
2481
|
// comparison-domain changes), before DEFAULT / NOT NULL.
|
|
2422
|
-
|
|
2482
|
+
for (const s of comparisonDomainAlters(quotedTable, quotedCol, colAlter))
|
|
2483
|
+
pushText(s);
|
|
2423
2484
|
if (colAlter.defaultValue !== undefined) {
|
|
2424
2485
|
if (colAlter.defaultValue === null) {
|
|
2425
|
-
|
|
2486
|
+
// Already dropped above when it preceded the retype.
|
|
2487
|
+
if (!colAlter.dropStaleDefaultFirst) {
|
|
2488
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedCol} DROP DEFAULT`);
|
|
2489
|
+
}
|
|
2426
2490
|
}
|
|
2427
2491
|
else {
|
|
2428
|
-
|
|
2492
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedCol} SET DEFAULT ${expressionToString(colAlter.defaultValue)}`);
|
|
2429
2493
|
}
|
|
2430
2494
|
}
|
|
2431
2495
|
if (colAlter.notNull !== undefined) {
|
|
2432
|
-
|
|
2496
|
+
pushText(colAlter.notNull
|
|
2433
2497
|
? `ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedCol} SET NOT NULL`
|
|
2434
2498
|
: `ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedCol} DROP NOT NULL`);
|
|
2435
2499
|
}
|
|
@@ -2438,10 +2502,10 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2438
2502
|
// conflicting constraint), both BEFORE re-adds and before the PK change so a
|
|
2439
2503
|
// dropped UNIQUE can't strand a PK dependency.
|
|
2440
2504
|
for (const r of alter.constraintsToRename ?? []) {
|
|
2441
|
-
|
|
2505
|
+
pushText(`ALTER TABLE ${quotedTable} RENAME CONSTRAINT ${quoteIdentifier(r.oldName)} TO ${quoteIdentifier(r.newName)}`);
|
|
2442
2506
|
}
|
|
2443
2507
|
for (const name of alter.constraintsToDrop ?? []) {
|
|
2444
|
-
|
|
2508
|
+
pushText(`ALTER TABLE ${quotedTable} DROP CONSTRAINT ${quoteIdentifier(name)}`);
|
|
2445
2509
|
}
|
|
2446
2510
|
if (alter.primaryKeyChange) {
|
|
2447
2511
|
const pkCols = alter.primaryKeyChange.newPkColumns
|
|
@@ -2452,16 +2516,16 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2452
2516
|
return s;
|
|
2453
2517
|
})
|
|
2454
2518
|
.join(', ');
|
|
2455
|
-
|
|
2519
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER PRIMARY KEY (${pkCols})`);
|
|
2456
2520
|
}
|
|
2457
2521
|
// ADD CONSTRAINT after the PK change (a new UNIQUE / FK may align with the new
|
|
2458
2522
|
// key) and after the column adds it may reference. CHECK adds apply in-place;
|
|
2459
2523
|
// UNIQUE / FK adds depend on module ADD CONSTRAINT support (see constraintsToAdd).
|
|
2460
2524
|
for (const frag of alter.constraintsToAdd ?? []) {
|
|
2461
|
-
|
|
2525
|
+
pushText(`ALTER TABLE ${quotedTable} ADD ${frag}`);
|
|
2462
2526
|
}
|
|
2463
2527
|
for (const colName of alter.columnsToDrop) {
|
|
2464
|
-
|
|
2528
|
+
pushText(`ALTER TABLE ${quotedTable} DROP COLUMN ${quoteIdentifier(colName)}`);
|
|
2465
2529
|
}
|
|
2466
2530
|
// Tags phase — last, so a SET TAGS lands on the post-structural column /
|
|
2467
2531
|
// constraint set (a tag set emitted alongside a RENAME COLUMN targets the
|
|
@@ -2472,23 +2536,25 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2472
2536
|
// TABLE handler rejects a tag action on a maintained table). See
|
|
2473
2537
|
// `TableAlterDiff.maintainedTags`.
|
|
2474
2538
|
const tagVerb = alter.maintainedTags ? 'ALTER MATERIALIZED VIEW' : 'ALTER TABLE';
|
|
2475
|
-
|
|
2539
|
+
pushText(`${tagVerb} ${quotedTable} SET TAGS ${tagsBodyToString(alter.tableTagsChange)}`);
|
|
2476
2540
|
}
|
|
2477
2541
|
for (const colAlter of alter.columnsToAlter) {
|
|
2478
2542
|
if (colAlter.tags === undefined)
|
|
2479
2543
|
continue;
|
|
2480
|
-
|
|
2544
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quoteIdentifier(colAlter.columnName)} SET TAGS ${tagsBodyToString(colAlter.tags)}`);
|
|
2481
2545
|
}
|
|
2482
2546
|
for (const ctc of alter.constraintTagsChanges ?? []) {
|
|
2483
|
-
|
|
2547
|
+
pushText(`ALTER TABLE ${quotedTable} ALTER CONSTRAINT ${quoteIdentifier(ctc.constraintName)} SET TAGS ${tagsBodyToString(ctc.tags)}`);
|
|
2484
2548
|
}
|
|
2485
2549
|
}
|
|
2486
2550
|
// Attach / re-attach maintained tables (`set maintained as`) LATE — where MV
|
|
2487
2551
|
// creates ran — after every table create/alter, so the target's final shape and
|
|
2488
2552
|
// the body's sources already exist (and any reshape leg's `drop maintained` +
|
|
2489
2553
|
// column ops have run). A same-shape re-attach reconciles content in place (a
|
|
2490
|
-
// refresh, not a recreate).
|
|
2491
|
-
//
|
|
2554
|
+
// refresh, not a recreate). Built as a synthetic `set maintained as` action and
|
|
2555
|
+
// rendered via `astToString`, so the body QueryExpr round-trips exactly — and
|
|
2556
|
+
// carried on the step so `apply schema` executes that statement rather than
|
|
2557
|
+
// re-parsing the render.
|
|
2492
2558
|
for (const alter of diff.tablesToAlter) {
|
|
2493
2559
|
if (!alter.setMaintained)
|
|
2494
2560
|
continue;
|
|
@@ -2506,7 +2572,7 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2506
2572
|
select: alter.setMaintained.select,
|
|
2507
2573
|
},
|
|
2508
2574
|
};
|
|
2509
|
-
statements.push(astToString(stmt));
|
|
2575
|
+
statements.push({ sql: astToString(stmt), ast: stmt });
|
|
2510
2576
|
}
|
|
2511
2577
|
// Assertion creates LAST — after every table alter and maintained re-attach, so
|
|
2512
2578
|
// a body sees the final shape of every object. `CREATE ASSERTION` plans its
|
|
@@ -2523,10 +2589,10 @@ export function generateMigrationDDL(diff, schemaName) {
|
|
|
2523
2589
|
// table's tag-only change rides the table-alter block above (`SET TAGS`), not a
|
|
2524
2590
|
// separate bucket.
|
|
2525
2591
|
for (const vtc of diff.viewTagsChanges ?? []) {
|
|
2526
|
-
|
|
2592
|
+
pushText(`ALTER VIEW ${schemaPrefix}${quoteIdentifier(vtc.name)} SET TAGS ${tagsBodyToString(vtc.tags)}`);
|
|
2527
2593
|
}
|
|
2528
2594
|
for (const itc of diff.indexTagsChanges ?? []) {
|
|
2529
|
-
|
|
2595
|
+
pushText(`ALTER INDEX ${schemaPrefix}${quoteIdentifier(itc.name)} SET TAGS ${tagsBodyToString(itc.tags)}`);
|
|
2530
2596
|
}
|
|
2531
2597
|
return statements;
|
|
2532
2598
|
}
|