@intentius/chant-lexicon-sql 0.0.0-stage → 0.112.1
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/README.md +39 -2
- package/dist/clickhouse/apply/apply.d.ts +82 -0
- package/dist/clickhouse/apply/apply.d.ts.map +1 -0
- package/dist/clickhouse/apply/mutations.d.ts +46 -0
- package/dist/clickhouse/apply/mutations.d.ts.map +1 -0
- package/dist/clickhouse/apply/statements.d.ts +99 -0
- package/dist/clickhouse/apply/statements.d.ts.map +1 -0
- package/dist/clickhouse/catalog-types.d.ts +76 -0
- package/dist/clickhouse/catalog-types.d.ts.map +1 -0
- package/dist/clickhouse/container.d.ts +63 -0
- package/dist/clickhouse/container.d.ts.map +1 -0
- package/dist/clickhouse/engine-syntax.d.ts +43 -0
- package/dist/clickhouse/engine-syntax.d.ts.map +1 -0
- package/dist/clickhouse/entities.d.ts +183 -0
- package/dist/clickhouse/entities.d.ts.map +1 -0
- package/dist/clickhouse/http.d.ts +40 -0
- package/dist/clickhouse/http.d.ts.map +1 -0
- package/dist/clickhouse/import/generator.d.ts +16 -0
- package/dist/clickhouse/import/generator.d.ts.map +1 -0
- package/dist/clickhouse/import/ir.d.ts +52 -0
- package/dist/clickhouse/import/ir.d.ts.map +1 -0
- package/dist/clickhouse/import/live-export.d.ts +28 -0
- package/dist/clickhouse/import/live-export.d.ts.map +1 -0
- package/dist/clickhouse/import/parser.d.ts +10 -0
- package/dist/clickhouse/import/parser.d.ts.map +1 -0
- package/dist/clickhouse/live/bind.d.ts +56 -0
- package/dist/clickhouse/live/bind.d.ts.map +1 -0
- package/dist/clickhouse/live/catalog.d.ts +39 -0
- package/dist/clickhouse/live/catalog.d.ts.map +1 -0
- package/dist/clickhouse/live/describe-resources.d.ts +34 -0
- package/dist/clickhouse/live/describe-resources.d.ts.map +1 -0
- package/dist/clickhouse/overlays/codecs.d.ts +28 -0
- package/dist/clickhouse/overlays/codecs.d.ts.map +1 -0
- package/dist/clickhouse/overlays/engines.d.ts +20 -0
- package/dist/clickhouse/overlays/engines.d.ts.map +1 -0
- package/dist/clickhouse/overlays/kinds.d.ts +38 -0
- package/dist/clickhouse/overlays/kinds.d.ts.map +1 -0
- package/dist/clickhouse/overlays/projections.d.ts +27 -0
- package/dist/clickhouse/overlays/projections.d.ts.map +1 -0
- package/dist/clickhouse/overlays/skip-indexes.d.ts +10 -0
- package/dist/clickhouse/overlays/skip-indexes.d.ts.map +1 -0
- package/dist/clickhouse/overlays/ttl.d.ts +35 -0
- package/dist/clickhouse/overlays/ttl.d.ts.map +1 -0
- package/dist/clickhouse/overlays/types.d.ts +21 -0
- package/dist/clickhouse/overlays/types.d.ts.map +1 -0
- package/dist/clickhouse/ownership.d.ts +71 -0
- package/dist/clickhouse/ownership.d.ts.map +1 -0
- package/dist/clickhouse/parser.d.ts +130 -0
- package/dist/clickhouse/parser.d.ts.map +1 -0
- package/dist/clickhouse/plan/commands.d.ts +26 -0
- package/dist/clickhouse/plan/commands.d.ts.map +1 -0
- package/dist/clickhouse/plan/deep.d.ts +32 -0
- package/dist/clickhouse/plan/deep.d.ts.map +1 -0
- package/dist/clickhouse/plan/diff.d.ts +37 -0
- package/dist/clickhouse/plan/diff.d.ts.map +1 -0
- package/dist/clickhouse/plan/disruption.d.ts +17 -0
- package/dist/clickhouse/plan/disruption.d.ts.map +1 -0
- package/dist/clickhouse/plan/normalize.d.ts +97 -0
- package/dist/clickhouse/plan/normalize.d.ts.map +1 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts +38 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts.map +1 -0
- package/dist/clickhouse/plan/report.d.ts +6 -0
- package/dist/clickhouse/plan/report.d.ts.map +1 -0
- package/dist/clickhouse/plan/rules.d.ts +60 -0
- package/dist/clickhouse/plan/rules.d.ts.map +1 -0
- package/dist/clickhouse/plan/schema.d.ts +23 -0
- package/dist/clickhouse/plan/schema.d.ts.map +1 -0
- package/dist/clickhouse/plan/server-format.d.ts +12 -0
- package/dist/clickhouse/plan/server-format.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/backfill.d.ts +70 -0
- package/dist/clickhouse/rebuild/backfill.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/observe.d.ts +157 -0
- package/dist/clickhouse/rebuild/observe.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/op.d.ts +108 -0
- package/dist/clickhouse/rebuild/op.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/partitions.d.ts +24 -0
- package/dist/clickhouse/rebuild/partitions.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/receipts.d.ts +76 -0
- package/dist/clickhouse/rebuild/receipts.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/replicas.d.ts +78 -0
- package/dist/clickhouse/rebuild/replicas.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/steps.d.ts +151 -0
- package/dist/clickhouse/rebuild/steps.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/verify.d.ts +51 -0
- package/dist/clickhouse/rebuild/verify.d.ts.map +1 -0
- package/dist/clickhouse/testing/fake-server.d.ts +27 -0
- package/dist/clickhouse/testing/fake-server.d.ts.map +1 -0
- package/dist/clickhouse/testing/roundtrip-schema.d.ts +3 -0
- package/dist/clickhouse/testing/roundtrip-schema.d.ts.map +1 -0
- package/dist/clickhouse/testing/writable-server.d.ts +35 -0
- package/dist/clickhouse/testing/writable-server.d.ts.map +1 -0
- package/dist/clickhouse/tokens.d.ts +15 -0
- package/dist/clickhouse/tokens.d.ts.map +1 -0
- package/dist/clickhouse.d.ts +24 -0
- package/dist/clickhouse.d.ts.map +1 -0
- package/dist/codegen/classifier-page.d.ts +6 -0
- package/dist/codegen/classifier-page.d.ts.map +1 -0
- package/dist/codegen/clickhouse-module.d.ts +23 -0
- package/dist/codegen/clickhouse-module.d.ts.map +1 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts +8 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/generate-cli.d.ts +3 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts +40 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +7 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/codegen/postgres-classifier-page.d.ts +7 -0
- package/dist/codegen/postgres-classifier-page.d.ts.map +1 -0
- package/dist/codegen/postgres-module.d.ts +30 -0
- package/dist/codegen/postgres-module.d.ts.map +1 -0
- package/dist/codegen/registry.d.ts +12 -0
- package/dist/codegen/registry.d.ts.map +1 -0
- package/dist/composites/audit-log-table.d.ts +31 -0
- package/dist/composites/audit-log-table.d.ts.map +1 -0
- package/dist/composites/catalog.d.ts +3 -0
- package/dist/composites/catalog.d.ts.map +1 -0
- package/dist/composites/cdc-mirror.d.ts +32 -0
- package/dist/composites/cdc-mirror.d.ts.map +1 -0
- package/dist/composites/clickhouse.d.ts +7 -0
- package/dist/composites/clickhouse.d.ts.map +1 -0
- package/dist/composites/events-table.d.ts +32 -0
- package/dist/composites/events-table.d.ts.map +1 -0
- package/dist/composites/index.d.ts +9 -0
- package/dist/composites/index.d.ts.map +1 -0
- package/dist/composites/join-table.d.ts +41 -0
- package/dist/composites/join-table.d.ts.map +1 -0
- package/dist/composites/postgres.d.ts +7 -0
- package/dist/composites/postgres.d.ts.map +1 -0
- package/dist/composites/refreshed-view.d.ts +32 -0
- package/dist/composites/refreshed-view.d.ts.map +1 -0
- package/dist/composites/replacing-table.d.ts +34 -0
- package/dist/composites/replacing-table.d.ts.map +1 -0
- package/dist/composites/rollup-view.d.ts +39 -0
- package/dist/composites/rollup-view.d.ts.map +1 -0
- package/dist/composites/sharded-table.d.ts +35 -0
- package/dist/composites/sharded-table.d.ts.map +1 -0
- package/dist/composites/soft-delete-table.d.ts +40 -0
- package/dist/composites/soft-delete-table.d.ts.map +1 -0
- package/dist/composites/tenant-table.d.ts +34 -0
- package/dist/composites/tenant-table.d.ts.map +1 -0
- package/dist/config.d.ts +213 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/apply.d.ts +89 -0
- package/dist/core/apply.d.ts.map +1 -0
- package/dist/core/classifier.d.ts +88 -0
- package/dist/core/classifier.d.ts.map +1 -0
- package/dist/core/container.d.ts +45 -0
- package/dist/core/container.d.ts.map +1 -0
- package/dist/core/cursor.d.ts +67 -0
- package/dist/core/cursor.d.ts.map +1 -0
- package/dist/core/diff.d.ts +49 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/entity.d.ts +41 -0
- package/dist/core/entity.d.ts.map +1 -0
- package/dist/core/find-templates.d.ts +69 -0
- package/dist/core/find-templates.d.ts.map +1 -0
- package/dist/core/handoff.d.ts +36 -0
- package/dist/core/handoff.d.ts.map +1 -0
- package/dist/core/index.d.ts +61 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/interpolation.d.ts +88 -0
- package/dist/core/interpolation.d.ts.map +1 -0
- package/dist/core/normalize.d.ts +18 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/ownership.d.ts +60 -0
- package/dist/core/ownership.d.ts.map +1 -0
- package/dist/core/receipts.d.ts +28 -0
- package/dist/core/receipts.d.ts.map +1 -0
- package/dist/core/references.d.ts +37 -0
- package/dist/core/references.d.ts.map +1 -0
- package/dist/core/template.d.ts +41 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/testing/http-stub.d.ts +17 -0
- package/dist/core/testing/http-stub.d.ts.map +1 -0
- package/dist/core/tokens.d.ts +102 -0
- package/dist/core/tokens.d.ts.map +1 -0
- package/dist/coverage.d.ts +25 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/detect.d.ts +15 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/dialects.d.ts +20 -0
- package/dist/dialects.d.ts.map +1 -0
- package/dist/generated/clickhouse-types.d.ts +4380 -0
- package/dist/generated/clickhouse-types.d.ts.map +1 -0
- package/dist/generated/clickhouse.d.ts +11 -0
- package/dist/generated/clickhouse.d.ts.map +1 -0
- package/dist/generated/postgres-types.d.ts +1579 -0
- package/dist/generated/postgres-types.d.ts.map +1 -0
- package/dist/generated/postgres.d.ts +9 -0
- package/dist/generated/postgres.d.ts.map +1 -0
- package/dist/import-generator.d.ts +8 -0
- package/dist/import-generator.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/init-templates.d.ts +20 -0
- package/dist/init-templates.d.ts.map +1 -0
- package/dist/integrity.json +61 -0
- package/dist/lint/audit-catalog.d.ts +10 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/audit-lineage.d.ts +25 -0
- package/dist/lint/audit-lineage.d.ts.map +1 -0
- package/dist/lint/post-synth/audit-entries.d.ts +8 -0
- package/dist/lint/post-synth/audit-entries.d.ts.map +1 -0
- package/dist/lint/post-synth/clickhouse-helpers.d.ts +85 -0
- package/dist/lint/post-synth/clickhouse-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/post-synth/postgres-audit-entries.d.ts +9 -0
- package/dist/lint/post-synth/postgres-audit-entries.d.ts.map +1 -0
- package/dist/lint/post-synth/postgres-helpers.d.ts +89 -0
- package/dist/lint/post-synth/postgres-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/sql-helpers.d.ts +27 -0
- package/dist/lint/post-synth/sql-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch101.d.ts +12 -0
- package/dist/lint/post-synth/sqlch101.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch102.d.ts +9 -0
- package/dist/lint/post-synth/sqlch102.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch103.d.ts +10 -0
- package/dist/lint/post-synth/sqlch103.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch104.d.ts +9 -0
- package/dist/lint/post-synth/sqlch104.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch105.d.ts +10 -0
- package/dist/lint/post-synth/sqlch105.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch106.d.ts +11 -0
- package/dist/lint/post-synth/sqlch106.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch107.d.ts +10 -0
- package/dist/lint/post-synth/sqlch107.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch108.d.ts +11 -0
- package/dist/lint/post-synth/sqlch108.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch109.d.ts +10 -0
- package/dist/lint/post-synth/sqlch109.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch110.d.ts +12 -0
- package/dist/lint/post-synth/sqlch110.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch111.d.ts +11 -0
- package/dist/lint/post-synth/sqlch111.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch112.d.ts +12 -0
- package/dist/lint/post-synth/sqlch112.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch113.d.ts +9 -0
- package/dist/lint/post-synth/sqlch113.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch114.d.ts +8 -0
- package/dist/lint/post-synth/sqlch114.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch115.d.ts +13 -0
- package/dist/lint/post-synth/sqlch115.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch116.d.ts +10 -0
- package/dist/lint/post-synth/sqlch116.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch117.d.ts +9 -0
- package/dist/lint/post-synth/sqlch117.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch118.d.ts +10 -0
- package/dist/lint/post-synth/sqlch118.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch119.d.ts +11 -0
- package/dist/lint/post-synth/sqlch119.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch120.d.ts +10 -0
- package/dist/lint/post-synth/sqlch120.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg101.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg101.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg102.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg102.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg103.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg103.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg104.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg104.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg105.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg105.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg106.d.ts +9 -0
- package/dist/lint/post-synth/sqlpg106.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg107.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg107.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg108.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg108.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg109.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg109.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg110.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg110.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg111.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg111.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg112.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg112.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg113.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg113.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg114.d.ts +13 -0
- package/dist/lint/post-synth/sqlpg114.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg115.d.ts +13 -0
- package/dist/lint/post-synth/sqlpg115.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg116.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg116.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg117.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg117.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg118.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg118.d.ts.map +1 -0
- package/dist/lint/rules/index.d.ts +12 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/postgres-templates.d.ts +18 -0
- package/dist/lint/rules/postgres-templates.d.ts.map +1 -0
- package/dist/lint/rules/sqlch001.d.ts +12 -0
- package/dist/lint/rules/sqlch001.d.ts.map +1 -0
- package/dist/lint/rules/sqlch002.d.ts +11 -0
- package/dist/lint/rules/sqlch002.d.ts.map +1 -0
- package/dist/lint/rules/sqlch003.d.ts +12 -0
- package/dist/lint/rules/sqlch003.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg001.d.ts +16 -0
- package/dist/lint/rules/sqlpg001.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg002.d.ts +12 -0
- package/dist/lint/rules/sqlpg002.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg003.d.ts +16 -0
- package/dist/lint/rules/sqlpg003.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg004.d.ts +21 -0
- package/dist/lint/rules/sqlpg004.d.ts.map +1 -0
- package/dist/lint/rules/templates.d.ts +23 -0
- package/dist/lint/rules/templates.d.ts.map +1 -0
- package/dist/live-dialect.d.ts +25 -0
- package/dist/live-dialect.d.ts.map +1 -0
- package/dist/lsp/catalog.d.ts +22 -0
- package/dist/lsp/catalog.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +13 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/hover.d.ts +12 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/postgres-catalog.d.ts +85 -0
- package/dist/lsp/postgres-catalog.d.ts.map +1 -0
- package/dist/lsp/postgres-template.d.ts +35 -0
- package/dist/lsp/postgres-template.d.ts.map +1 -0
- package/dist/lsp/postgres.d.ts +20 -0
- package/dist/lsp/postgres.d.ts.map +1 -0
- package/dist/lsp/refs.d.ts +8 -0
- package/dist/lsp/refs.d.ts.map +1 -0
- package/dist/lsp/registry.d.ts +4 -0
- package/dist/lsp/registry.d.ts.map +1 -0
- package/dist/lsp/template.d.ts +34 -0
- package/dist/lsp/template.d.ts.map +1 -0
- package/dist/manifest.json +8 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/postgres.d.ts +32 -0
- package/dist/mcp/postgres.d.ts.map +1 -0
- package/dist/meta.json +67 -0
- package/dist/okf/index.md +67 -0
- package/dist/okf/rules/SQLCH001.md +11 -0
- package/dist/okf/rules/SQLCH002.md +11 -0
- package/dist/okf/rules/SQLCH003.md +11 -0
- package/dist/okf/rules/SQLCH101.md +15 -0
- package/dist/okf/rules/SQLCH102.md +11 -0
- package/dist/okf/rules/SQLCH103.md +11 -0
- package/dist/okf/rules/SQLCH104.md +11 -0
- package/dist/okf/rules/SQLCH105.md +11 -0
- package/dist/okf/rules/SQLCH106.md +11 -0
- package/dist/okf/rules/SQLCH107.md +11 -0
- package/dist/okf/rules/SQLCH108.md +15 -0
- package/dist/okf/rules/SQLCH109.md +11 -0
- package/dist/okf/rules/SQLCH110.md +11 -0
- package/dist/okf/rules/SQLCH111.md +11 -0
- package/dist/okf/rules/SQLCH112.md +11 -0
- package/dist/okf/rules/SQLCH113.md +11 -0
- package/dist/okf/rules/SQLCH114.md +11 -0
- package/dist/okf/rules/SQLCH115.md +11 -0
- package/dist/okf/rules/SQLCH116.md +11 -0
- package/dist/okf/rules/SQLCH117.md +15 -0
- package/dist/okf/rules/SQLCH118.md +15 -0
- package/dist/okf/rules/SQLCH119.md +15 -0
- package/dist/okf/rules/SQLCH120.md +15 -0
- package/dist/okf/rules/SQLPG001.md +11 -0
- package/dist/okf/rules/SQLPG002.md +11 -0
- package/dist/okf/rules/SQLPG003.md +11 -0
- package/dist/okf/rules/SQLPG004.md +11 -0
- package/dist/okf/rules/SQLPG101.md +11 -0
- package/dist/okf/rules/SQLPG102.md +11 -0
- package/dist/okf/rules/SQLPG103.md +11 -0
- package/dist/okf/rules/SQLPG104.md +11 -0
- package/dist/okf/rules/SQLPG105.md +11 -0
- package/dist/okf/rules/SQLPG106.md +11 -0
- package/dist/okf/rules/SQLPG107.md +11 -0
- package/dist/okf/rules/SQLPG108.md +11 -0
- package/dist/okf/rules/SQLPG109.md +11 -0
- package/dist/okf/rules/SQLPG110.md +11 -0
- package/dist/okf/rules/SQLPG111.md +11 -0
- package/dist/okf/rules/SQLPG112.md +11 -0
- package/dist/okf/rules/SQLPG113.md +24 -0
- package/dist/okf/rules/SQLPG114.md +11 -0
- package/dist/okf/rules/SQLPG115.md +11 -0
- package/dist/okf/rules/SQLPG116.md +15 -0
- package/dist/okf/rules/SQLPG117.md +11 -0
- package/dist/okf/rules/SQLPG118.md +11 -0
- package/dist/okf/types/Database.md +15 -0
- package/dist/okf/types/MaterializedView.md +14 -0
- package/dist/okf/types/PostgresDomain.md +13 -0
- package/dist/okf/types/PostgresEnum.md +13 -0
- package/dist/okf/types/PostgresExtension.md +13 -0
- package/dist/okf/types/PostgresIndex.md +9 -0
- package/dist/okf/types/PostgresMaterializedView.md +13 -0
- package/dist/okf/types/PostgresSchema.md +13 -0
- package/dist/okf/types/PostgresSequence.md +13 -0
- package/dist/okf/types/PostgresTable.md +13 -0
- package/dist/okf/types/PostgresView.md +13 -0
- package/dist/okf/types/Table.md +15 -0
- package/dist/okf/types/View.md +13 -0
- package/dist/op/activities/clickhouse-apply.d.ts +56 -0
- package/dist/op/activities/clickhouse-apply.d.ts.map +1 -0
- package/dist/op/activities/clickhouse-emulator.d.ts +26 -0
- package/dist/op/activities/clickhouse-emulator.d.ts.map +1 -0
- package/dist/op/activities/clickhouse-rebuild.d.ts +43 -0
- package/dist/op/activities/clickhouse-rebuild.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +19 -0
- package/dist/op/activities/index.d.ts.map +1 -0
- package/dist/op/activities/postgres-apply.d.ts +69 -0
- package/dist/op/activities/postgres-apply.d.ts.map +1 -0
- package/dist/op/activities/postgres-emulator.d.ts +33 -0
- package/dist/op/activities/postgres-emulator.d.ts.map +1 -0
- package/dist/op/activities/postgres-migration.d.ts +48 -0
- package/dist/op/activities/postgres-migration.d.ts.map +1 -0
- package/dist/op/activity-contracts.d.ts +464 -0
- package/dist/op/activity-contracts.d.ts.map +1 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/postgres/apply/apply.d.ts +163 -0
- package/dist/postgres/apply/apply.d.ts.map +1 -0
- package/dist/postgres/apply/statements.d.ts +138 -0
- package/dist/postgres/apply/statements.d.ts.map +1 -0
- package/dist/postgres/catalog-types.d.ts +50 -0
- package/dist/postgres/catalog-types.d.ts.map +1 -0
- package/dist/postgres/container.d.ts +23 -0
- package/dist/postgres/container.d.ts.map +1 -0
- package/dist/postgres/entities.d.ts +322 -0
- package/dist/postgres/entities.d.ts.map +1 -0
- package/dist/postgres/entity-types.d.ts +17 -0
- package/dist/postgres/entity-types.d.ts.map +1 -0
- package/dist/postgres/import/generator.d.ts +28 -0
- package/dist/postgres/import/generator.d.ts.map +1 -0
- package/dist/postgres/import/ir.d.ts +24 -0
- package/dist/postgres/import/ir.d.ts.map +1 -0
- package/dist/postgres/import/live-export.d.ts +26 -0
- package/dist/postgres/import/live-export.d.ts.map +1 -0
- package/dist/postgres/keywords.d.ts +22 -0
- package/dist/postgres/keywords.d.ts.map +1 -0
- package/dist/postgres/live/bind.d.ts +76 -0
- package/dist/postgres/live/bind.d.ts.map +1 -0
- package/dist/postgres/live/catalog.d.ts +98 -0
- package/dist/postgres/live/catalog.d.ts.map +1 -0
- package/dist/postgres/live/client.d.ts +32 -0
- package/dist/postgres/live/client.d.ts.map +1 -0
- package/dist/postgres/live/describe-resources.d.ts +41 -0
- package/dist/postgres/live/describe-resources.d.ts.map +1 -0
- package/dist/postgres/migrate/backfill.d.ts +103 -0
- package/dist/postgres/migrate/backfill.d.ts.map +1 -0
- package/dist/postgres/migrate/batches.d.ts +90 -0
- package/dist/postgres/migrate/batches.d.ts.map +1 -0
- package/dist/postgres/migrate/carry.d.ts +196 -0
- package/dist/postgres/migrate/carry.d.ts.map +1 -0
- package/dist/postgres/migrate/handoff.d.ts +46 -0
- package/dist/postgres/migrate/handoff.d.ts.map +1 -0
- package/dist/postgres/migrate/names.d.ts +55 -0
- package/dist/postgres/migrate/names.d.ts.map +1 -0
- package/dist/postgres/migrate/observe.d.ts +139 -0
- package/dist/postgres/migrate/observe.d.ts.map +1 -0
- package/dist/postgres/migrate/op.d.ts +128 -0
- package/dist/postgres/migrate/op.d.ts.map +1 -0
- package/dist/postgres/migrate/receipts.d.ts +63 -0
- package/dist/postgres/migrate/receipts.d.ts.map +1 -0
- package/dist/postgres/migrate/replication.d.ts +80 -0
- package/dist/postgres/migrate/replication.d.ts.map +1 -0
- package/dist/postgres/migrate/steps.d.ts +225 -0
- package/dist/postgres/migrate/steps.d.ts.map +1 -0
- package/dist/postgres/overlays/columns.d.ts +6 -0
- package/dist/postgres/overlays/columns.d.ts.map +1 -0
- package/dist/postgres/overlays/constraints.d.ts +8 -0
- package/dist/postgres/overlays/constraints.d.ts.map +1 -0
- package/dist/postgres/overlays/indexes.d.ts +8 -0
- package/dist/postgres/overlays/indexes.d.ts.map +1 -0
- package/dist/postgres/overlays/kinds.d.ts +48 -0
- package/dist/postgres/overlays/kinds.d.ts.map +1 -0
- package/dist/postgres/overlays/partitioning.d.ts +5 -0
- package/dist/postgres/overlays/partitioning.d.ts.map +1 -0
- package/dist/postgres/overlays/relations.d.ts +6 -0
- package/dist/postgres/overlays/relations.d.ts.map +1 -0
- package/dist/postgres/overlays/storage.d.ts +28 -0
- package/dist/postgres/overlays/storage.d.ts.map +1 -0
- package/dist/postgres/overlays/type-ddl.d.ts +7 -0
- package/dist/postgres/overlays/type-ddl.d.ts.map +1 -0
- package/dist/postgres/overlays/types.d.ts +24 -0
- package/dist/postgres/overlays/types.d.ts.map +1 -0
- package/dist/postgres/parser.d.ts +216 -0
- package/dist/postgres/parser.d.ts.map +1 -0
- package/dist/postgres/plan/commands.d.ts +61 -0
- package/dist/postgres/plan/commands.d.ts.map +1 -0
- package/dist/postgres/plan/deep.d.ts +33 -0
- package/dist/postgres/plan/deep.d.ts.map +1 -0
- package/dist/postgres/plan/diff.d.ts +45 -0
- package/dist/postgres/plan/diff.d.ts.map +1 -0
- package/dist/postgres/plan/disruption.d.ts +14 -0
- package/dist/postgres/plan/disruption.d.ts.map +1 -0
- package/dist/postgres/plan/normalize.d.ts +108 -0
- package/dist/postgres/plan/normalize.d.ts.map +1 -0
- package/dist/postgres/plan/report.d.ts +6 -0
- package/dist/postgres/plan/report.d.ts.map +1 -0
- package/dist/postgres/plan/rules.d.ts +84 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -0
- package/dist/postgres/plan/schema.d.ts +50 -0
- package/dist/postgres/plan/schema.d.ts.map +1 -0
- package/dist/postgres/plan/server-normalize.d.ts +26 -0
- package/dist/postgres/plan/server-normalize.d.ts.map +1 -0
- package/dist/postgres/providers/aurora.d.ts +12 -0
- package/dist/postgres/providers/aurora.d.ts.map +1 -0
- package/dist/postgres/providers/azure.d.ts +14 -0
- package/dist/postgres/providers/azure.d.ts.map +1 -0
- package/dist/postgres/providers/cloud-sql.d.ts +11 -0
- package/dist/postgres/providers/cloud-sql.d.ts.map +1 -0
- package/dist/postgres/providers/index.d.ts +35 -0
- package/dist/postgres/providers/index.d.ts.map +1 -0
- package/dist/postgres/providers/neon.d.ts +13 -0
- package/dist/postgres/providers/neon.d.ts.map +1 -0
- package/dist/postgres/providers/rds.d.ts +10 -0
- package/dist/postgres/providers/rds.d.ts.map +1 -0
- package/dist/postgres/providers/supabase.d.ts +12 -0
- package/dist/postgres/providers/supabase.d.ts.map +1 -0
- package/dist/postgres/providers/types.d.ts +59 -0
- package/dist/postgres/providers/types.d.ts.map +1 -0
- package/dist/postgres/testing/fake-client.d.ts +38 -0
- package/dist/postgres/testing/fake-client.d.ts.map +1 -0
- package/dist/postgres/testing/migration.d.ts +25 -0
- package/dist/postgres/testing/migration.d.ts.map +1 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts +11 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts.map +1 -0
- package/dist/postgres/testing/server.d.ts +17 -0
- package/dist/postgres/testing/server.d.ts.map +1 -0
- package/dist/postgres/testing/writable-server.d.ts +45 -0
- package/dist/postgres/testing/writable-server.d.ts.map +1 -0
- package/dist/postgres/tokens.d.ts +26 -0
- package/dist/postgres/tokens.d.ts.map +1 -0
- package/dist/postgres.d.ts +13 -0
- package/dist/postgres.d.ts.map +1 -0
- package/dist/rules/audit-entries.ts +29 -0
- package/dist/rules/clickhouse-helpers.ts +206 -0
- package/dist/rules/postgres-audit-entries.ts +29 -0
- package/dist/rules/postgres-helpers.ts +126 -0
- package/dist/rules/postgres-templates.ts +36 -0
- package/dist/rules/sql-helpers.ts +53 -0
- package/dist/rules/sqlch001.ts +53 -0
- package/dist/rules/sqlch002.ts +115 -0
- package/dist/rules/sqlch003.ts +68 -0
- package/dist/rules/sqlch101.ts +35 -0
- package/dist/rules/sqlch102.ts +23 -0
- package/dist/rules/sqlch103.ts +45 -0
- package/dist/rules/sqlch104.ts +42 -0
- package/dist/rules/sqlch105.ts +35 -0
- package/dist/rules/sqlch106.ts +27 -0
- package/dist/rules/sqlch107.ts +35 -0
- package/dist/rules/sqlch108.ts +27 -0
- package/dist/rules/sqlch109.ts +21 -0
- package/dist/rules/sqlch110.ts +29 -0
- package/dist/rules/sqlch111.ts +40 -0
- package/dist/rules/sqlch112.ts +30 -0
- package/dist/rules/sqlch113.ts +20 -0
- package/dist/rules/sqlch114.ts +26 -0
- package/dist/rules/sqlch115.ts +31 -0
- package/dist/rules/sqlch116.ts +22 -0
- package/dist/rules/sqlch117.ts +25 -0
- package/dist/rules/sqlch118.ts +26 -0
- package/dist/rules/sqlch119.ts +31 -0
- package/dist/rules/sqlch120.ts +21 -0
- package/dist/rules/sqlpg001.ts +88 -0
- package/dist/rules/sqlpg002.ts +68 -0
- package/dist/rules/sqlpg003.ts +59 -0
- package/dist/rules/sqlpg004.ts +73 -0
- package/dist/rules/sqlpg101.ts +24 -0
- package/dist/rules/sqlpg102.ts +30 -0
- package/dist/rules/sqlpg103.ts +23 -0
- package/dist/rules/sqlpg104.ts +23 -0
- package/dist/rules/sqlpg105.ts +22 -0
- package/dist/rules/sqlpg106.ts +22 -0
- package/dist/rules/sqlpg107.ts +22 -0
- package/dist/rules/sqlpg108.ts +27 -0
- package/dist/rules/sqlpg109.ts +37 -0
- package/dist/rules/sqlpg110.ts +33 -0
- package/dist/rules/sqlpg111.ts +23 -0
- package/dist/rules/sqlpg112.ts +25 -0
- package/dist/rules/sqlpg113.ts +28 -0
- package/dist/rules/sqlpg114.ts +37 -0
- package/dist/rules/sqlpg115.ts +38 -0
- package/dist/rules/sqlpg116.ts +25 -0
- package/dist/rules/sqlpg117.ts +24 -0
- package/dist/rules/sqlpg118.ts +22 -0
- package/dist/rules/templates.ts +35 -0
- package/dist/serializer.d.ts +37 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/skill-defs.d.ts +3 -0
- package/dist/skill-defs.d.ts.map +1 -0
- package/dist/spec/catalog.d.ts +125 -0
- package/dist/spec/catalog.d.ts.map +1 -0
- package/dist/spec/fetch.d.ts +43 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/pin.d.ts +39 -0
- package/dist/spec/pin.d.ts.map +1 -0
- package/dist/spec/postgres-catalog.d.ts +108 -0
- package/dist/spec/postgres-catalog.d.ts.map +1 -0
- package/dist/spec/postgres-fetch.d.ts +46 -0
- package/dist/spec/postgres-fetch.d.ts.map +1 -0
- package/dist/spec/postgres-pin.d.ts +67 -0
- package/dist/spec/postgres-pin.d.ts.map +1 -0
- package/dist/types/index.d.ts +4386 -0
- package/dist/validate-cli.d.ts +3 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate.d.ts +15 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +74 -4
- package/src/clickhouse/apply/apply.ts +288 -0
- package/src/clickhouse/apply/mutations.ts +90 -0
- package/src/clickhouse/apply/statements.ts +393 -0
- package/src/clickhouse/catalog-types.ts +84 -0
- package/src/clickhouse/container.ts +176 -0
- package/src/clickhouse/engine-syntax.test.ts +53 -0
- package/src/clickhouse/engine-syntax.ts +173 -0
- package/src/clickhouse/entities.test.ts +188 -0
- package/src/clickhouse/entities.ts +425 -0
- package/src/clickhouse/http.ts +76 -0
- package/src/clickhouse/import/generator.ts +153 -0
- package/src/clickhouse/import/import.test.ts +157 -0
- package/src/clickhouse/import/ir.ts +171 -0
- package/src/clickhouse/import/live-export.ts +53 -0
- package/src/clickhouse/import/parser.ts +27 -0
- package/src/clickhouse/import/roundtrip.test.ts +90 -0
- package/src/clickhouse/live/bind.ts +126 -0
- package/src/clickhouse/live/catalog.ts +96 -0
- package/src/clickhouse/live/describe-resources.ts +98 -0
- package/src/clickhouse/live/live.test.ts +143 -0
- package/src/clickhouse/live/roundtrip.e2e.test.ts +93 -0
- package/src/clickhouse/overlays/codecs.ts +68 -0
- package/src/clickhouse/overlays/engines.ts +108 -0
- package/src/clickhouse/overlays/kinds.ts +38 -0
- package/src/clickhouse/overlays/projections.ts +36 -0
- package/src/clickhouse/overlays/skip-indexes.ts +44 -0
- package/src/clickhouse/overlays/ttl.ts +55 -0
- package/src/clickhouse/overlays/types.ts +58 -0
- package/src/clickhouse/ownership.test.ts +20 -0
- package/src/clickhouse/ownership.ts +103 -0
- package/src/clickhouse/parser.test.ts +166 -0
- package/src/clickhouse/parser.ts +459 -0
- package/src/clickhouse/plan/commands.ts +101 -0
- package/src/clickhouse/plan/deep.ts +124 -0
- package/src/clickhouse/plan/diff.ts +203 -0
- package/src/clickhouse/plan/disruption.ts +61 -0
- package/src/clickhouse/plan/normalize.ts +352 -0
- package/src/clickhouse/plan/plan-wiring.test.ts +77 -0
- package/src/clickhouse/plan/plan.e2e.test.ts +77 -0
- package/src/clickhouse/plan/plan.test.ts +201 -0
- package/src/clickhouse/plan/rebuild-handoff.ts +59 -0
- package/src/clickhouse/plan/report.ts +19 -0
- package/src/clickhouse/plan/rules.ts +241 -0
- package/src/clickhouse/plan/schema.ts +56 -0
- package/src/clickhouse/plan/server-format.ts +39 -0
- package/src/clickhouse/rebuild/backfill.ts +186 -0
- package/src/clickhouse/rebuild/observe.ts +380 -0
- package/src/clickhouse/rebuild/op.ts +206 -0
- package/src/clickhouse/rebuild/partitions.ts +62 -0
- package/src/clickhouse/rebuild/rebuild-replicated.e2e.test.ts +513 -0
- package/src/clickhouse/rebuild/rebuild.e2e.test.ts +351 -0
- package/src/clickhouse/rebuild/rebuild.test.ts +190 -0
- package/src/clickhouse/rebuild/receipts.ts +143 -0
- package/src/clickhouse/rebuild/replicas.test.ts +70 -0
- package/src/clickhouse/rebuild/replicas.ts +148 -0
- package/src/clickhouse/rebuild/steps.ts +382 -0
- package/src/clickhouse/rebuild/verify.ts +124 -0
- package/src/clickhouse/testdata/NOTICE +5 -0
- package/src/clickhouse/testdata/clickhouse-tests-corpus.json +302 -0
- package/src/clickhouse/testing/fake-server.ts +65 -0
- package/src/clickhouse/testing/roundtrip-schema.ts +25 -0
- package/src/clickhouse/testing/writable-server.ts +141 -0
- package/src/clickhouse/tokens.ts +28 -0
- package/src/clickhouse.ts +63 -0
- package/src/codegen/classifier-page.test.ts +16 -0
- package/src/codegen/classifier-page.ts +76 -0
- package/src/codegen/clickhouse-module.test.ts +63 -0
- package/src/codegen/clickhouse-module.ts +269 -0
- package/src/codegen/docs-cli.ts +4 -0
- package/src/codegen/docs.ts +225 -0
- package/src/codegen/generate-cli.ts +13 -0
- package/src/codegen/generate.ts +126 -0
- package/src/codegen/package.ts +36 -0
- package/src/codegen/postgres-classifier-page.ts +81 -0
- package/src/codegen/postgres-module.test.ts +77 -0
- package/src/codegen/postgres-module.ts +434 -0
- package/src/codegen/registry.ts +36 -0
- package/src/composites/audit-log-table.ts +54 -0
- package/src/composites/catalog.test.ts +61 -0
- package/src/composites/catalog.ts +529 -0
- package/src/composites/cdc-mirror.ts +54 -0
- package/src/composites/clickhouse.ts +7 -0
- package/src/composites/composites.test.ts +758 -0
- package/src/composites/events-table.ts +49 -0
- package/src/composites/index.ts +9 -0
- package/src/composites/join-table.ts +57 -0
- package/src/composites/postgres.ts +7 -0
- package/src/composites/refreshed-view.ts +46 -0
- package/src/composites/replacing-table.ts +49 -0
- package/src/composites/rollup-view.ts +55 -0
- package/src/composites/sharded-table.ts +49 -0
- package/src/composites/soft-delete-table.ts +61 -0
- package/src/composites/tenant-table.ts +50 -0
- package/src/config.ts +157 -0
- package/src/core/apply.ts +153 -0
- package/src/core/classifier.ts +186 -0
- package/src/core/container.ts +93 -0
- package/src/core/core.test.ts +254 -0
- package/src/core/cursor.ts +189 -0
- package/src/core/diff.ts +72 -0
- package/src/core/entity.ts +85 -0
- package/src/core/find-templates.ts +158 -0
- package/src/core/handoff.ts +44 -0
- package/src/core/index.ts +61 -0
- package/src/core/interpolation.ts +225 -0
- package/src/core/normalize.ts +39 -0
- package/src/core/ownership.test.ts +36 -0
- package/src/core/ownership.ts +133 -0
- package/src/core/receipts.ts +29 -0
- package/src/core/references.ts +74 -0
- package/src/core/template.ts +83 -0
- package/src/core/testing/http-stub.ts +33 -0
- package/src/core/tokens.ts +252 -0
- package/src/coverage.ts +64 -0
- package/src/detect.ts +32 -0
- package/src/dialects.ts +21 -0
- package/src/generated/clickhouse-types.ts +4386 -0
- package/src/generated/clickhouse.ts +2476 -0
- package/src/generated/index.d.ts +4386 -0
- package/src/generated/lexicon-sql.json +67 -0
- package/src/generated/postgres-types.ts +1190 -0
- package/src/generated/postgres.ts +1039 -0
- package/src/import-generator.ts +18 -0
- package/src/index.ts +21 -0
- package/src/init-templates.test.ts +108 -0
- package/src/init-templates.ts +327 -0
- package/src/lint/audit-catalog.ts +73 -0
- package/src/lint/audit-lineage.ts +47 -0
- package/src/lint/post-synth/audit-entries.ts +29 -0
- package/src/lint/post-synth/clickhouse-checks.test.ts +278 -0
- package/src/lint/post-synth/clickhouse-helpers.ts +206 -0
- package/src/lint/post-synth/index.ts +81 -0
- package/src/lint/post-synth/post-synth.test.ts +33 -0
- package/src/lint/post-synth/postgres-audit-entries.ts +29 -0
- package/src/lint/post-synth/postgres-checks.test.ts +257 -0
- package/src/lint/post-synth/postgres-helpers.ts +126 -0
- package/src/lint/post-synth/sql-helpers.ts +53 -0
- package/src/lint/post-synth/sqlch101.ts +35 -0
- package/src/lint/post-synth/sqlch102.ts +23 -0
- package/src/lint/post-synth/sqlch103.ts +45 -0
- package/src/lint/post-synth/sqlch104.ts +42 -0
- package/src/lint/post-synth/sqlch105.ts +35 -0
- package/src/lint/post-synth/sqlch106.ts +27 -0
- package/src/lint/post-synth/sqlch107.ts +35 -0
- package/src/lint/post-synth/sqlch108.ts +27 -0
- package/src/lint/post-synth/sqlch109.ts +21 -0
- package/src/lint/post-synth/sqlch110.ts +29 -0
- package/src/lint/post-synth/sqlch111.ts +40 -0
- package/src/lint/post-synth/sqlch112.ts +30 -0
- package/src/lint/post-synth/sqlch113.ts +20 -0
- package/src/lint/post-synth/sqlch114.ts +26 -0
- package/src/lint/post-synth/sqlch115.ts +31 -0
- package/src/lint/post-synth/sqlch116.ts +22 -0
- package/src/lint/post-synth/sqlch117.ts +25 -0
- package/src/lint/post-synth/sqlch118.ts +26 -0
- package/src/lint/post-synth/sqlch119.ts +31 -0
- package/src/lint/post-synth/sqlch120.ts +21 -0
- package/src/lint/post-synth/sqlpg101.ts +24 -0
- package/src/lint/post-synth/sqlpg102.ts +30 -0
- package/src/lint/post-synth/sqlpg103.ts +23 -0
- package/src/lint/post-synth/sqlpg104.ts +23 -0
- package/src/lint/post-synth/sqlpg105.ts +22 -0
- package/src/lint/post-synth/sqlpg106.ts +22 -0
- package/src/lint/post-synth/sqlpg107.ts +22 -0
- package/src/lint/post-synth/sqlpg108.ts +27 -0
- package/src/lint/post-synth/sqlpg109.ts +37 -0
- package/src/lint/post-synth/sqlpg110.ts +33 -0
- package/src/lint/post-synth/sqlpg111.ts +23 -0
- package/src/lint/post-synth/sqlpg112.ts +25 -0
- package/src/lint/post-synth/sqlpg113.ts +28 -0
- package/src/lint/post-synth/sqlpg114.ts +37 -0
- package/src/lint/post-synth/sqlpg115.ts +38 -0
- package/src/lint/post-synth/sqlpg116.ts +25 -0
- package/src/lint/post-synth/sqlpg117.ts +24 -0
- package/src/lint/post-synth/sqlpg118.ts +22 -0
- package/src/lint/rules/index.ts +13 -0
- package/src/lint/rules/postgres-templates.ts +36 -0
- package/src/lint/rules/rules.test.ts +228 -0
- package/src/lint/rules/sqlch001.ts +53 -0
- package/src/lint/rules/sqlch002.ts +115 -0
- package/src/lint/rules/sqlch003.ts +68 -0
- package/src/lint/rules/sqlpg001.ts +88 -0
- package/src/lint/rules/sqlpg002.ts +68 -0
- package/src/lint/rules/sqlpg003.ts +59 -0
- package/src/lint/rules/sqlpg004.ts +73 -0
- package/src/lint/rules/templates.ts +35 -0
- package/src/live-dialect.ts +37 -0
- package/src/lsp/catalog.ts +60 -0
- package/src/lsp/completions.test.ts +111 -0
- package/src/lsp/completions.ts +128 -0
- package/src/lsp/diagnostics.test.ts +26 -0
- package/src/lsp/hover.test.ts +90 -0
- package/src/lsp/hover.ts +113 -0
- package/src/lsp/postgres-catalog.ts +234 -0
- package/src/lsp/postgres-template.ts +161 -0
- package/src/lsp/postgres.test.ts +150 -0
- package/src/lsp/postgres.ts +270 -0
- package/src/lsp/refs.ts +53 -0
- package/src/lsp/registry.ts +19 -0
- package/src/lsp/template.ts +166 -0
- package/src/mcp/index.ts +304 -0
- package/src/mcp/mcp.test.ts +184 -0
- package/src/mcp/postgres.ts +125 -0
- package/src/op/activities/clickhouse-apply.e2e.test.ts +150 -0
- package/src/op/activities/clickhouse-apply.test.ts +265 -0
- package/src/op/activities/clickhouse-apply.ts +113 -0
- package/src/op/activities/clickhouse-emulator.test.ts +23 -0
- package/src/op/activities/clickhouse-emulator.ts +37 -0
- package/src/op/activities/clickhouse-rebuild.ts +136 -0
- package/src/op/activities/index.ts +50 -0
- package/src/op/activities/postgres-apply.e2e.test.ts +184 -0
- package/src/op/activities/postgres-apply.test.ts +304 -0
- package/src/op/activities/postgres-apply.ts +170 -0
- package/src/op/activities/postgres-emulator.test.ts +26 -0
- package/src/op/activities/postgres-emulator.ts +44 -0
- package/src/op/activities/postgres-migration.ts +182 -0
- package/src/op/activity-contracts.ts +210 -0
- package/src/package-cli.ts +17 -0
- package/src/plugin.test.ts +74 -0
- package/src/plugin.ts +242 -0
- package/src/postgres/apply/apply.ts +582 -0
- package/src/postgres/apply/statements.test.ts +155 -0
- package/src/postgres/apply/statements.ts +603 -0
- package/src/postgres/catalog-types.ts +59 -0
- package/src/postgres/container.ts +72 -0
- package/src/postgres/entities.test.ts +170 -0
- package/src/postgres/entities.ts +1016 -0
- package/src/postgres/entity-types.ts +18 -0
- package/src/postgres/import/generator.ts +176 -0
- package/src/postgres/import/import.test.ts +71 -0
- package/src/postgres/import/ir.ts +67 -0
- package/src/postgres/import/live-export.ts +53 -0
- package/src/postgres/import/live-warnings.test.ts +45 -0
- package/src/postgres/keywords.ts +40 -0
- package/src/postgres/live/bind.ts +146 -0
- package/src/postgres/live/catalog.ts +581 -0
- package/src/postgres/live/client.ts +84 -0
- package/src/postgres/live/describe-resources.ts +111 -0
- package/src/postgres/live/live.test.ts +198 -0
- package/src/postgres/live/roundtrip.e2e.test.ts +111 -0
- package/src/postgres/migrate/backfill.ts +233 -0
- package/src/postgres/migrate/batches.e2e.test.ts +163 -0
- package/src/postgres/migrate/batches.test.ts +36 -0
- package/src/postgres/migrate/batches.ts +159 -0
- package/src/postgres/migrate/carry.e2e.test.ts +335 -0
- package/src/postgres/migrate/carry.test.ts +103 -0
- package/src/postgres/migrate/carry.ts +653 -0
- package/src/postgres/migrate/handoff.ts +73 -0
- package/src/postgres/migrate/kinds.e2e.test.ts +204 -0
- package/src/postgres/migrate/migrate.e2e.test.ts +362 -0
- package/src/postgres/migrate/migrate.test.ts +322 -0
- package/src/postgres/migrate/names.ts +93 -0
- package/src/postgres/migrate/observe.ts +521 -0
- package/src/postgres/migrate/op.ts +242 -0
- package/src/postgres/migrate/receipts.ts +135 -0
- package/src/postgres/migrate/replication.ts +151 -0
- package/src/postgres/migrate/steps.ts +657 -0
- package/src/postgres/overlays/columns.ts +34 -0
- package/src/postgres/overlays/constraints.ts +56 -0
- package/src/postgres/overlays/indexes.ts +27 -0
- package/src/postgres/overlays/kinds.ts +53 -0
- package/src/postgres/overlays/partitioning.ts +26 -0
- package/src/postgres/overlays/relations.ts +29 -0
- package/src/postgres/overlays/storage.ts +75 -0
- package/src/postgres/overlays/type-ddl.ts +38 -0
- package/src/postgres/overlays/types.ts +56 -0
- package/src/postgres/parser.test.ts +214 -0
- package/src/postgres/parser.ts +1062 -0
- package/src/postgres/plan/commands.ts +124 -0
- package/src/postgres/plan/deep.ts +177 -0
- package/src/postgres/plan/diff.ts +323 -0
- package/src/postgres/plan/disruption.ts +52 -0
- package/src/postgres/plan/normalize.test.ts +148 -0
- package/src/postgres/plan/normalize.ts +542 -0
- package/src/postgres/plan/plan.e2e.test.ts +117 -0
- package/src/postgres/plan/plan.test.ts +244 -0
- package/src/postgres/plan/report.ts +24 -0
- package/src/postgres/plan/rules.ts +276 -0
- package/src/postgres/plan/schema.ts +114 -0
- package/src/postgres/plan/server-normalize.ts +123 -0
- package/src/postgres/providers/aurora.ts +45 -0
- package/src/postgres/providers/azure.ts +54 -0
- package/src/postgres/providers/cloud-sql.ts +42 -0
- package/src/postgres/providers/index.ts +90 -0
- package/src/postgres/providers/neon.ts +45 -0
- package/src/postgres/providers/providers.test.ts +136 -0
- package/src/postgres/providers/rds.ts +48 -0
- package/src/postgres/providers/supabase.ts +46 -0
- package/src/postgres/providers/types.ts +70 -0
- package/src/postgres/testdata/NOTICE +31 -0
- package/src/postgres/testdata/postgres-regress-corpus.json +460 -0
- package/src/postgres/testing/fake-client.ts +42 -0
- package/src/postgres/testing/migration.ts +52 -0
- package/src/postgres/testing/roundtrip-schema.ts +46 -0
- package/src/postgres/testing/server.ts +58 -0
- package/src/postgres/testing/writable-server.ts +188 -0
- package/src/postgres/tokens.ts +46 -0
- package/src/postgres.ts +75 -0
- package/src/serializer.test.ts +128 -0
- package/src/serializer.ts +148 -0
- package/src/skill-defs.test.ts +81 -0
- package/src/skill-defs.ts +102 -0
- package/src/skills/chant-sql-plan.md +123 -0
- package/src/skills/chant-sql-postgres-migration.md +126 -0
- package/src/skills/chant-sql-postgres-plan.md +194 -0
- package/src/skills/chant-sql-postgres.md +165 -0
- package/src/skills/chant-sql-rebuild.md +68 -0
- package/src/skills/chant-sql.md +123 -0
- package/src/spec/catalog.e2e.test.ts +29 -0
- package/src/spec/catalog.test.ts +56 -0
- package/src/spec/catalog.ts +311 -0
- package/src/spec/clickhouse-catalog.snapshot.json +5246 -0
- package/src/spec/fetch.test.ts +77 -0
- package/src/spec/fetch.ts +112 -0
- package/src/spec/pin.ts +47 -0
- package/src/spec/postgres-catalog-14.snapshot.json +3494 -0
- package/src/spec/postgres-catalog-15.snapshot.json +3529 -0
- package/src/spec/postgres-catalog-16.snapshot.json +3597 -0
- package/src/spec/postgres-catalog-17.snapshot.json +3656 -0
- package/src/spec/postgres-catalog-18.snapshot.json +3747 -0
- package/src/spec/postgres-catalog.test.ts +43 -0
- package/src/spec/postgres-catalog.ts +301 -0
- package/src/spec/postgres-fetch.test.ts +75 -0
- package/src/spec/postgres-fetch.ts +112 -0
- package/src/spec/postgres-pin.test.ts +64 -0
- package/src/spec/postgres-pin.ts +101 -0
- package/src/typecheck.test.ts +104 -0
- package/src/validate-cli.ts +6 -0
- package/src/validate.ts +149 -0
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Postgres entities: `schema`, `table`, `index`, `view`, `sequence`,
|
|
3
|
+
* `type`, `domain` and `extension` tagged templates that parse their DDL at
|
|
4
|
+
* fold time into one Declarable each (chant #3278, #3279).
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { schema, table, index } from "@intentius/chant-lexicon-sql/postgres";
|
|
8
|
+
*
|
|
9
|
+
* export const app = schema`CREATE SCHEMA app`;
|
|
10
|
+
* export const users = table`
|
|
11
|
+
* CREATE TABLE ${app}.users (
|
|
12
|
+
* id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
13
|
+
* email text NOT NULL UNIQUE
|
|
14
|
+
* );
|
|
15
|
+
* COMMENT ON TABLE ${app}.users IS 'One row per account'`;
|
|
16
|
+
* export const usersEmail = index`CREATE INDEX users_email_idx ON ${users} (lower(${users.columns.email}))`;
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The export name is the object's identity in chant; the name in the SQL is
|
|
20
|
+
* its name in the database. An unquoted name folds to lower case, as Postgres
|
|
21
|
+
* folds it, so `CREATE TABLE Users` is `users` and `.columns` is keyed by the
|
|
22
|
+
* folded name.
|
|
23
|
+
*
|
|
24
|
+
* What an interpolation means is decided by its value, as for ClickHouse
|
|
25
|
+
* (#3235):
|
|
26
|
+
*
|
|
27
|
+
* - a Postgres entity is a reference to that object and renders as its
|
|
28
|
+
* schema-qualified name; a schema renders as its name, so `${app}.users`
|
|
29
|
+
* reads `app.users`;
|
|
30
|
+
* - `entity.columns.<name>` is a reference to one column, and renders as the
|
|
31
|
+
* column's name (write `u.${users.columns.id}` in a join);
|
|
32
|
+
* - a sequence inside `nextval(...)`, `currval(...)` or `setval(...)`, and any
|
|
33
|
+
* object followed by `::regclass`, renders as a `regclass` literal:
|
|
34
|
+
* `DEFAULT nextval(${ticketSeq})` reads `nextval('app.ticket_seq'::regclass)`,
|
|
35
|
+
* which is also how the catalog prints it, and the table depends on the
|
|
36
|
+
* sequence;
|
|
37
|
+
* - a string is SQL text, spliced into the statement before it is parsed;
|
|
38
|
+
* - a number or bigint is a numeric literal, a boolean `true`/`false`, `null`
|
|
39
|
+
* is `NULL`;
|
|
40
|
+
* - `literal(value)` is a quoted string literal (`'` doubled; a backslash is an
|
|
41
|
+
* ordinary character, since standard_conforming_strings is on).
|
|
42
|
+
*
|
|
43
|
+
* Postgres has no inline comment clause, so a template may follow its CREATE
|
|
44
|
+
* with `COMMENT ON` statements for the same object, its columns and its
|
|
45
|
+
* constraints. They fold into the entity's `comment`, each column's and each
|
|
46
|
+
* constraint's, and stay in the DDL.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import type { AttrRef } from "@intentius/chant/attrref";
|
|
50
|
+
import { setInterpolationFields } from "@intentius/chant/provenance";
|
|
51
|
+
import { isTrivia, POSTGRES_LEXICAL, SqlSyntaxError, untokenize, type Token } from "./tokens";
|
|
52
|
+
import { identValue, parseStatements, type ColumnNode, type CommentNode, type ConstraintNode, type NameNode, type Span, type StatementNode } from "./parser";
|
|
53
|
+
import { keywordCategory, quoteIdent } from "./keywords";
|
|
54
|
+
import { feed, lineage, spanText as text, splice as spliceWith, templateSyntaxError, type TemplateCtx, type TemplateDialect } from "../core/interpolation";
|
|
55
|
+
import { SqlObject, isColumnRefOf, isSqlObjectOf, makeSqlEntity } from "../core/entity";
|
|
56
|
+
import type { LineageEdge } from "../core/references";
|
|
57
|
+
import { SqlLiteral, SqlTemplateError, describeValue as describe, stripUnset, templateParts } from "../core/template";
|
|
58
|
+
|
|
59
|
+
export { SQL_LEXICON } from "../core/entity";
|
|
60
|
+
export type { LineageEdge } from "../core/references";
|
|
61
|
+
export { SqlLiteral, SqlTemplateError } from "../core/template";
|
|
62
|
+
export { quoteIdent } from "./keywords";
|
|
63
|
+
|
|
64
|
+
export { POSTGRES_ENTITY_TYPES, type PostgresEntityType } from "./entity-types";
|
|
65
|
+
import { POSTGRES_ENTITY_TYPES, type PostgresEntityType } from "./entity-types";
|
|
66
|
+
|
|
67
|
+
// ── Values ─────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/** A column as declared. Expressions are the source text with interpolations rendered. */
|
|
70
|
+
export interface ColumnDef {
|
|
71
|
+
name: string;
|
|
72
|
+
/** Absent on a typed table (`OF type`) or a partition, whose columns take their type elsewhere. */
|
|
73
|
+
type?: string;
|
|
74
|
+
/** `NOT NULL` (true) or `NULL` (false), when written. */
|
|
75
|
+
notNull?: boolean;
|
|
76
|
+
/** The name given to the column's NOT NULL constraint. */
|
|
77
|
+
notNullName?: string;
|
|
78
|
+
default?: string;
|
|
79
|
+
/** `GENERATED ALWAYS AS (expr) STORED | VIRTUAL`, or `GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [(options)]`. */
|
|
80
|
+
generated?: { kind: "stored" | "virtual" | "identity"; expr?: string; always: boolean; options?: string };
|
|
81
|
+
collate?: string;
|
|
82
|
+
compression?: string;
|
|
83
|
+
storage?: string;
|
|
84
|
+
comment?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Deferral attributes, on the constraints that take them. */
|
|
88
|
+
interface Deferral {
|
|
89
|
+
deferrable?: boolean;
|
|
90
|
+
initiallyDeferred?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface KeyDef extends Deferral {
|
|
94
|
+
name?: string;
|
|
95
|
+
columns: string[];
|
|
96
|
+
nullsNotDistinct?: boolean;
|
|
97
|
+
include?: string;
|
|
98
|
+
with?: string;
|
|
99
|
+
comment?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface CheckDef {
|
|
103
|
+
name?: string;
|
|
104
|
+
expr: string;
|
|
105
|
+
noInherit?: boolean;
|
|
106
|
+
notValid?: boolean;
|
|
107
|
+
notEnforced?: boolean;
|
|
108
|
+
comment?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ForeignKeyDef extends Deferral {
|
|
112
|
+
name?: string;
|
|
113
|
+
columns: string[];
|
|
114
|
+
/** The referenced table: the entity when it is interpolated, else its name as written. */
|
|
115
|
+
references: PostgresObject | string;
|
|
116
|
+
/** The referenced table's SQL name, schema-qualified as written. */
|
|
117
|
+
refTable: string;
|
|
118
|
+
/** The referenced columns; empty means the referenced table's primary key. */
|
|
119
|
+
refColumns: string[];
|
|
120
|
+
match?: string;
|
|
121
|
+
onDelete?: string;
|
|
122
|
+
onUpdate?: string;
|
|
123
|
+
notValid?: boolean;
|
|
124
|
+
notEnforced?: boolean;
|
|
125
|
+
comment?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface ExclusionDef extends Deferral {
|
|
129
|
+
name?: string;
|
|
130
|
+
using?: string;
|
|
131
|
+
/** The element list, `col WITH op, ...`, as written. */
|
|
132
|
+
elements: string;
|
|
133
|
+
where?: string;
|
|
134
|
+
include?: string;
|
|
135
|
+
with?: string;
|
|
136
|
+
comment?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface CommonProps {
|
|
140
|
+
/** The object's name in the database, folded as Postgres folds it. */
|
|
141
|
+
name: string;
|
|
142
|
+
/** The schema the DDL qualifies it with. */
|
|
143
|
+
schema?: string;
|
|
144
|
+
comment?: string;
|
|
145
|
+
/** The statements as they will be sent: the author's text, interpolations rendered. */
|
|
146
|
+
ddl: string;
|
|
147
|
+
/** The template's raw parts, as written, for a source round trip. */
|
|
148
|
+
source: { strings: string[] };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface SchemaProps extends Omit<CommonProps, "schema"> {
|
|
152
|
+
ifNotExists?: boolean;
|
|
153
|
+
authorization?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface TableProps extends CommonProps {
|
|
157
|
+
persistence?: "temporary" | "unlogged";
|
|
158
|
+
ifNotExists?: boolean;
|
|
159
|
+
/** `PARTITION OF parent`: the entity when interpolated, else its name. */
|
|
160
|
+
partitionOf?: PostgresObject | string;
|
|
161
|
+
partitionBound?: string;
|
|
162
|
+
/** `OF type`: the entity when interpolated, else its name. */
|
|
163
|
+
ofType?: PostgresObject | string;
|
|
164
|
+
columns: ColumnDef[];
|
|
165
|
+
primaryKey?: KeyDef;
|
|
166
|
+
uniques: KeyDef[];
|
|
167
|
+
checks: CheckDef[];
|
|
168
|
+
foreignKeys: ForeignKeyDef[];
|
|
169
|
+
exclusions: ExclusionDef[];
|
|
170
|
+
/** `LIKE source [options]` clauses, as written. */
|
|
171
|
+
like: string[];
|
|
172
|
+
inherits: Array<PostgresObject | string>;
|
|
173
|
+
partitionBy?: string;
|
|
174
|
+
using?: string;
|
|
175
|
+
/** Storage parameters, as written: `(fillfactor = 70)`. */
|
|
176
|
+
with?: string;
|
|
177
|
+
onCommit?: string;
|
|
178
|
+
tablespace?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface IndexProps extends CommonProps {
|
|
182
|
+
/** The indexed table: the entity when interpolated, else its name. */
|
|
183
|
+
table: PostgresObject | string;
|
|
184
|
+
/** The indexed table's SQL name. */
|
|
185
|
+
tableName: string;
|
|
186
|
+
unique?: boolean;
|
|
187
|
+
/** `CREATE INDEX CONCURRENTLY`: the classifier and the applier read it, since it refuses a transaction block. */
|
|
188
|
+
concurrently?: boolean;
|
|
189
|
+
ifNotExists?: boolean;
|
|
190
|
+
only?: boolean;
|
|
191
|
+
/** The access method (`btree`, `gin`, ...), when written. */
|
|
192
|
+
method?: string;
|
|
193
|
+
elements: Array<{ expr: string; column?: string }>;
|
|
194
|
+
include?: string;
|
|
195
|
+
nullsNotDistinct?: boolean;
|
|
196
|
+
with?: string;
|
|
197
|
+
tablespace?: string;
|
|
198
|
+
where?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface ViewProps extends CommonProps {
|
|
202
|
+
orReplace?: boolean;
|
|
203
|
+
recursive?: boolean;
|
|
204
|
+
temporary?: boolean;
|
|
205
|
+
ifNotExists?: boolean;
|
|
206
|
+
/** The declared column list; empty when the view names its outputs in its query. */
|
|
207
|
+
columns: string[];
|
|
208
|
+
with?: string;
|
|
209
|
+
using?: string;
|
|
210
|
+
tablespace?: string;
|
|
211
|
+
query: string;
|
|
212
|
+
checkOption?: string;
|
|
213
|
+
/** `WITH DATA` (true) or `WITH NO DATA` (false), for a materialized view. */
|
|
214
|
+
withData?: boolean;
|
|
215
|
+
/** The objects the query reads, as references. */
|
|
216
|
+
reads: PostgresObject[];
|
|
217
|
+
/** Per output column of the top-level select list, the columns it reads. */
|
|
218
|
+
lineage: LineageEdge[];
|
|
219
|
+
/** `COMMENT ON COLUMN` for the view's outputs. */
|
|
220
|
+
columnComments?: Record<string, string>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface SequenceProps extends CommonProps {
|
|
224
|
+
persistence?: "temporary" | "unlogged";
|
|
225
|
+
ifNotExists?: boolean;
|
|
226
|
+
/** `AS type`: the sequence's data type. */
|
|
227
|
+
dataType?: string;
|
|
228
|
+
increment?: string;
|
|
229
|
+
/** A value, or `null` for `NO MINVALUE`. */
|
|
230
|
+
minValue?: string | null;
|
|
231
|
+
maxValue?: string | null;
|
|
232
|
+
start?: string;
|
|
233
|
+
cache?: string;
|
|
234
|
+
/** `CYCLE` (true) or `NO CYCLE` (false), when written. */
|
|
235
|
+
cycle?: boolean;
|
|
236
|
+
/** `OWNED BY table.column`, or `NONE`. */
|
|
237
|
+
ownedBy?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface EnumProps extends CommonProps {
|
|
241
|
+
labels: string[];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface DomainProps extends CommonProps {
|
|
245
|
+
/** The underlying data type. */
|
|
246
|
+
dataType: string;
|
|
247
|
+
collate?: string;
|
|
248
|
+
default?: string;
|
|
249
|
+
notNull?: boolean;
|
|
250
|
+
checks: CheckDef[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface ExtensionProps extends Omit<CommonProps, "schema"> {
|
|
254
|
+
/** `WITH SCHEMA`: the schema the extension's objects are created in. */
|
|
255
|
+
schema?: string;
|
|
256
|
+
version?: string;
|
|
257
|
+
cascade?: boolean;
|
|
258
|
+
ifNotExists?: boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* A string as a quoted Postgres string literal: `'` doubled, a backslash left
|
|
263
|
+
* as written (standard_conforming_strings is on). An interpolated plain string
|
|
264
|
+
* is SQL text; wrap it in `literal()` when it is a value.
|
|
265
|
+
*/
|
|
266
|
+
export function literal(value: string | number | boolean | null): SqlLiteral {
|
|
267
|
+
if (value === null) return new SqlLiteral("NULL");
|
|
268
|
+
if (typeof value !== "string") return new SqlLiteral(String(value));
|
|
269
|
+
return new SqlLiteral(`'${value.replace(/'/g, "''")}'`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ── Entities ───────────────────────────────────────────────────────────
|
|
273
|
+
|
|
274
|
+
/** The members a Postgres entity has besides its props (the shared core's {@link SqlObject}). */
|
|
275
|
+
export abstract class PostgresObject extends SqlObject {
|
|
276
|
+
declare readonly entityType: PostgresEntityType;
|
|
277
|
+
/** The name the object is referred to by in SQL: `name`, or `schema.name`, quoted where Postgres needs it. */
|
|
278
|
+
declare readonly sqlName: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface PostgresSchema extends PostgresObject {
|
|
282
|
+
readonly entityType: "Postgres::Schema";
|
|
283
|
+
readonly props: SchemaProps;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** A table or a view: something with columns that SQL can reference. */
|
|
287
|
+
export interface PostgresRelation extends PostgresObject {
|
|
288
|
+
/** One reference per column, by its folded name: `${users.columns.email}`. */
|
|
289
|
+
readonly columns: Readonly<Record<string, AttrRef>>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface PostgresTable extends PostgresRelation {
|
|
293
|
+
readonly entityType: "Postgres::Table";
|
|
294
|
+
readonly props: TableProps;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface PostgresView extends PostgresRelation {
|
|
298
|
+
readonly entityType: "Postgres::View" | "Postgres::MaterializedView";
|
|
299
|
+
readonly props: ViewProps;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface PostgresIndex extends PostgresObject {
|
|
303
|
+
readonly entityType: "Postgres::Index";
|
|
304
|
+
readonly props: IndexProps;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface PostgresSequence extends PostgresObject {
|
|
308
|
+
readonly entityType: "Postgres::Sequence";
|
|
309
|
+
readonly props: SequenceProps;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface PostgresEnum extends PostgresObject {
|
|
313
|
+
readonly entityType: "Postgres::Enum";
|
|
314
|
+
readonly props: EnumProps;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface PostgresDomain extends PostgresObject {
|
|
318
|
+
readonly entityType: "Postgres::Domain";
|
|
319
|
+
readonly props: DomainProps;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface PostgresExtension extends PostgresObject {
|
|
323
|
+
readonly entityType: "Postgres::Extension";
|
|
324
|
+
readonly props: ExtensionProps;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function isPostgresObject(value: unknown): value is PostgresObject {
|
|
328
|
+
return isSqlObjectOf(value, "Postgres::");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** A column reference: an AttrRef whose parent is a Postgres table or view. */
|
|
332
|
+
export function isColumnRef(value: unknown): value is AttrRef {
|
|
333
|
+
return isColumnRefOf(value, isPostgresObject);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ── Rendering interpolations ───────────────────────────────────────────
|
|
337
|
+
|
|
338
|
+
function renderReference(value: unknown): string {
|
|
339
|
+
if (isPostgresObject(value)) return value.sqlName;
|
|
340
|
+
if (isColumnRef(value)) return quoteIdent(value.attribute);
|
|
341
|
+
throw new TypeError(`not a reference: ${describe(value)}`);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** A name as a `regclass` literal's text: `'app.ticket_seq'`. */
|
|
345
|
+
const regclassText = (sqlName: string): string => `'${sqlName.replace(/'/g, "''")}'`;
|
|
346
|
+
|
|
347
|
+
/** Functions whose first argument is a `regclass`, written as a string (`nextval('s')`). */
|
|
348
|
+
const REGCLASS_FUNCTIONS = ["NEXTVAL", "CURRVAL", "SETVAL"];
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Interpolations that stand where Postgres wants a `regclass` literal: the
|
|
352
|
+
* first argument of `nextval`, `currval` or `setval`, rendered
|
|
353
|
+
* `'name'::regclass`; and an object followed by `::regclass`, rendered
|
|
354
|
+
* `'name'`. By value index.
|
|
355
|
+
*/
|
|
356
|
+
function regclassPositions(tokens: readonly Token[], values: readonly unknown[]): Map<number, "call" | "cast"> {
|
|
357
|
+
const out = new Map<number, "call" | "cast">();
|
|
358
|
+
const sig = tokens.filter((t) => !isTrivia(t));
|
|
359
|
+
sig.forEach((t, k) => {
|
|
360
|
+
if (t.kind !== "ref" || !isPostgresObject(values[t.part])) return;
|
|
361
|
+
const prev = sig[k - 1];
|
|
362
|
+
const fn = sig[k - 2];
|
|
363
|
+
const next = sig[k + 1];
|
|
364
|
+
if (
|
|
365
|
+
prev?.kind === "punct" && prev.text === "(" &&
|
|
366
|
+
fn?.kind === "ident" && REGCLASS_FUNCTIONS.includes(fn.text.toUpperCase()) &&
|
|
367
|
+
next?.kind === "punct" && (next.text === ")" || next.text === ",")
|
|
368
|
+
) {
|
|
369
|
+
out.set(t.part, "call");
|
|
370
|
+
} else if (next?.kind === "op" && next.text === "::" && sig[k + 2]?.kind === "ident" && sig[k + 2]!.text.toLowerCase() === "regclass") {
|
|
371
|
+
out.set(t.part, "cast");
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* The output name Postgres gives a select-list item with no alias
|
|
379
|
+
* (`FigureColname` in the parser): a column's name, a function's name, a
|
|
380
|
+
* cast's operand's name, `case` for a CASE, else `?column?`.
|
|
381
|
+
*/
|
|
382
|
+
function outputOf(items: readonly Token[], valueOf: (t: Token) => unknown): string | undefined {
|
|
383
|
+
const sig = items.filter((t) => !isTrivia(t));
|
|
384
|
+
if (sig.length === 0) return undefined;
|
|
385
|
+
// `x::type` names its output after `x`.
|
|
386
|
+
const cast = sig.findIndex((t) => t.kind === "op" && t.text === "::");
|
|
387
|
+
const head = cast > 0 ? sig.slice(0, cast) : sig;
|
|
388
|
+
const name = (t: Token): string | undefined => {
|
|
389
|
+
if (t.kind === "ident" || t.kind === "qident") return identValue(t);
|
|
390
|
+
const v = valueOf(t);
|
|
391
|
+
return isColumnRef(v) ? v.attribute : undefined;
|
|
392
|
+
};
|
|
393
|
+
const first = head[0]!;
|
|
394
|
+
const last = head[head.length - 1]!;
|
|
395
|
+
// A column, bare or qualified: `x`, `t.x`, `${t.columns.x}`, `t.${t.columns.x}`.
|
|
396
|
+
if (head.length === 1 || (head.length === 3 && head[1]!.kind === "punct" && head[1]!.text === ".")) {
|
|
397
|
+
const n = name(last);
|
|
398
|
+
if (n !== undefined) return n;
|
|
399
|
+
}
|
|
400
|
+
if (first.kind === "ident" && first.text.toUpperCase() === "CASE") return "case";
|
|
401
|
+
if (first.kind === "ident" && head[1]?.kind === "punct" && head[1].text === "(") return identValue(first);
|
|
402
|
+
return "?column?";
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Postgres as the shared template machinery reads it (`../core/interpolation.ts`). */
|
|
406
|
+
export const POSTGRES_TEMPLATES: TemplateDialect = {
|
|
407
|
+
lexical: POSTGRES_LEXICAL,
|
|
408
|
+
isObject: isPostgresObject,
|
|
409
|
+
isColumnRef,
|
|
410
|
+
renderReference,
|
|
411
|
+
identValue: (t) => identValue(t),
|
|
412
|
+
unnamedOutput: () => "?column?",
|
|
413
|
+
lineage: {
|
|
414
|
+
aliasWithoutAs: true,
|
|
415
|
+
keyword: (t) => {
|
|
416
|
+
const k = keywordCategory(t.text);
|
|
417
|
+
return k === undefined ? undefined : k === "R" ? "reserved" : "keyword";
|
|
418
|
+
},
|
|
419
|
+
distinctOn: true,
|
|
420
|
+
qualifiedRefs: true,
|
|
421
|
+
outputOf,
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// ── Building ───────────────────────────────────────────────────────────
|
|
426
|
+
|
|
427
|
+
type Ctx = TemplateCtx;
|
|
428
|
+
|
|
429
|
+
export type PostgresTag = "schema" | "table" | "index" | "view" | "sequence" | "type" | "domain" | "extension";
|
|
430
|
+
|
|
431
|
+
const STATEMENT_OF: Record<PostgresTag, StatementNode["statement"]> = {
|
|
432
|
+
schema: "schema",
|
|
433
|
+
table: "table",
|
|
434
|
+
index: "index",
|
|
435
|
+
view: "view",
|
|
436
|
+
sequence: "sequence",
|
|
437
|
+
type: "enum",
|
|
438
|
+
domain: "domain",
|
|
439
|
+
extension: "extension",
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
const TAG_OF: Record<StatementNode["statement"], PostgresTag | undefined> = {
|
|
443
|
+
schema: "schema",
|
|
444
|
+
table: "table",
|
|
445
|
+
index: "index",
|
|
446
|
+
view: "view",
|
|
447
|
+
sequence: "sequence",
|
|
448
|
+
enum: "type",
|
|
449
|
+
domain: "domain",
|
|
450
|
+
extension: "extension",
|
|
451
|
+
comment: undefined,
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
/** What each statement kind is called in a message. */
|
|
455
|
+
export const STATEMENT_NAMES: Record<StatementNode["statement"], string> = {
|
|
456
|
+
schema: "CREATE SCHEMA",
|
|
457
|
+
table: "CREATE TABLE",
|
|
458
|
+
index: "CREATE INDEX",
|
|
459
|
+
view: "CREATE VIEW",
|
|
460
|
+
sequence: "CREATE SEQUENCE",
|
|
461
|
+
enum: "CREATE TYPE",
|
|
462
|
+
domain: "CREATE DOMAIN",
|
|
463
|
+
extension: "CREATE EXTENSION",
|
|
464
|
+
comment: "COMMENT ON",
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/** Props without their unset fields and empty optional lists, so props hold only what the DDL says. */
|
|
468
|
+
const strip = <T extends object>(o: T, keep: readonly string[] = []): T =>
|
|
469
|
+
Object.fromEntries(
|
|
470
|
+
Object.entries(stripUnset(o)).filter(([k, v]) => keep.includes(k) || !(Array.isArray(v) && v.length === 0)),
|
|
471
|
+
) as T;
|
|
472
|
+
|
|
473
|
+
const req = (s: string | undefined): string => s ?? "";
|
|
474
|
+
|
|
475
|
+
/** A string constant's value: `'...'`, `E'...'`, `$tag$...$tag$`. */
|
|
476
|
+
export function stringValue(s: string | undefined): string | undefined {
|
|
477
|
+
if (s === undefined) return undefined;
|
|
478
|
+
let m = /^'(.*)'$/s.exec(s);
|
|
479
|
+
if (m) return m[1]!.replace(/''/g, "'");
|
|
480
|
+
m = /^[Ee]'(.*)'$/s.exec(s);
|
|
481
|
+
if (m) return m[1]!.replace(/''/g, "'").replace(/\\(.)/gs, (_, c: string) => ({ n: "\n", t: "\t", r: "\r", b: "\b", f: "\f" })[c] ?? c);
|
|
482
|
+
m = /^\$([A-Za-z_\u0080-][A-Za-z0-9_\u0080-]*)?\$(.*)\$\1\$$/s.exec(s);
|
|
483
|
+
if (m) return m[2];
|
|
484
|
+
return s;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** A qualified name's schema and name. An interpolated schema names the schema; an interpolated object gives both. */
|
|
488
|
+
function qualified(ctx: Ctx, n: NameNode): { schema?: string; name: string } {
|
|
489
|
+
const pieces: string[] = [];
|
|
490
|
+
const splices: Array<number | undefined> = [];
|
|
491
|
+
for (const t of ctx.tokens.slice(n.span.from, n.span.to)) {
|
|
492
|
+
if (isTrivia(t) || (t.kind === "punct" && t.text === ".")) continue;
|
|
493
|
+
if (t.kind === "ref") {
|
|
494
|
+
const v = ctx.values[t.part];
|
|
495
|
+
if (isPostgresObject(v)) {
|
|
496
|
+
const p = v.props as { schema?: string; name: string };
|
|
497
|
+
if (v.entityType !== POSTGRES_ENTITY_TYPES.schema && v.entityType !== POSTGRES_ENTITY_TYPES.extension && p.schema) {
|
|
498
|
+
pieces.push(p.schema);
|
|
499
|
+
splices.push(undefined);
|
|
500
|
+
}
|
|
501
|
+
pieces.push(p.name);
|
|
502
|
+
splices.push(undefined);
|
|
503
|
+
} else {
|
|
504
|
+
pieces.push(renderReference(v));
|
|
505
|
+
splices.push(undefined);
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
pieces.push(identValue(t));
|
|
509
|
+
splices.push(t.splice);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const last = pieces.length - 1;
|
|
513
|
+
splices.forEach((splice, i) => {
|
|
514
|
+
if (splice !== undefined) ctx.fed[splice]!.add(i === last ? "name" : "schema");
|
|
515
|
+
});
|
|
516
|
+
return pieces.length >= 2 ? { schema: pieces[pieces.length - 2], name: pieces[pieces.length - 1]! } : { name: pieces[0] ?? "" };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const sqlNameOf = (q: { schema?: string; name: string }): string => (q.schema ? `${quoteIdent(q.schema)}.${quoteIdent(q.name)}` : quoteIdent(q.name));
|
|
520
|
+
|
|
521
|
+
/** The object a name refers to: the entity when the whole name is one interpolation, else its SQL name. */
|
|
522
|
+
function target(ctx: Ctx, n: NameNode): PostgresObject | string {
|
|
523
|
+
const sig = ctx.tokens.slice(n.span.from, n.span.to).filter((t) => !isTrivia(t));
|
|
524
|
+
if (sig.length === 1 && sig[0]!.kind === "ref") {
|
|
525
|
+
const v = ctx.values[sig[0]!.part];
|
|
526
|
+
if (isPostgresObject(v)) return v;
|
|
527
|
+
}
|
|
528
|
+
return sqlNameOf(qualified(ctx, n));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** The SQL name of what a name refers to. */
|
|
532
|
+
const targetName = (ctx: Ctx, n: NameNode): string => {
|
|
533
|
+
const t = target(ctx, n);
|
|
534
|
+
return typeof t === "string" ? t : t.sqlName;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/** The name of a column in a key or reference list; an interpolated column reference gives its attribute. */
|
|
538
|
+
function columnName(ctx: Ctx, c: { name: string; span: Span }): string {
|
|
539
|
+
if (c.name) return c.name;
|
|
540
|
+
const t = ctx.tokens[c.span.from];
|
|
541
|
+
const v = t?.kind === "ref" ? ctx.values[t.part] : undefined;
|
|
542
|
+
return isColumnRef(v) ? v.attribute : req(text(ctx, c.span));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function columnDef(ctx: Ctx, c: ColumnNode): ColumnDef {
|
|
546
|
+
for (const span of [c.nameSpan, c.type, c.default, c.collate, c.compression, c.storage, c.generated?.expr, c.generated?.options]) feed(ctx, span, "columns");
|
|
547
|
+
const def: ColumnDef = { name: columnName(ctx, { name: c.name, span: c.nameSpan }) };
|
|
548
|
+
const set = <K extends keyof ColumnDef>(k: K, v: ColumnDef[K] | undefined) => {
|
|
549
|
+
if (v !== undefined) def[k] = v;
|
|
550
|
+
};
|
|
551
|
+
set("type", text(ctx, c.type));
|
|
552
|
+
set("notNull", c.notNull);
|
|
553
|
+
set("notNullName", c.notNullName);
|
|
554
|
+
set("default", text(ctx, c.default));
|
|
555
|
+
if (c.generated) {
|
|
556
|
+
def.generated = stripUnset({
|
|
557
|
+
kind: c.generated.kind,
|
|
558
|
+
expr: text(ctx, c.generated.expr),
|
|
559
|
+
always: c.generated.always,
|
|
560
|
+
options: text(ctx, c.generated.options),
|
|
561
|
+
});
|
|
562
|
+
// `always` false is meaningful for an identity column (BY DEFAULT).
|
|
563
|
+
def.generated.always = c.generated.always;
|
|
564
|
+
}
|
|
565
|
+
set("collate", text(ctx, c.collate));
|
|
566
|
+
set("compression", text(ctx, c.compression));
|
|
567
|
+
set("storage", text(ctx, c.storage));
|
|
568
|
+
return def;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function deferral(c: ConstraintNode): Deferral {
|
|
572
|
+
return stripUnset({ deferrable: c.deferrable, initiallyDeferred: c.initiallyDeferred });
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function keyDef(ctx: Ctx, c: ConstraintNode, columns: string[], path: string): KeyDef {
|
|
576
|
+
return strip(
|
|
577
|
+
{
|
|
578
|
+
name: c.name,
|
|
579
|
+
columns,
|
|
580
|
+
nullsNotDistinct: c.nullsNotDistinct,
|
|
581
|
+
include: text(ctx, c.include, path),
|
|
582
|
+
with: text(ctx, c.with, path),
|
|
583
|
+
...deferral(c),
|
|
584
|
+
},
|
|
585
|
+
["columns"],
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function checkDef(ctx: Ctx, c: ConstraintNode): CheckDef {
|
|
590
|
+
return stripUnset({
|
|
591
|
+
name: c.name,
|
|
592
|
+
expr: req(text(ctx, c.expr, "checks")),
|
|
593
|
+
noInherit: c.noInherit,
|
|
594
|
+
notValid: c.notValid,
|
|
595
|
+
notEnforced: c.notEnforced,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function foreignKeyDef(ctx: Ctx, c: ConstraintNode, columns: string[]): ForeignKeyDef {
|
|
600
|
+
const r = c.references!;
|
|
601
|
+
feed(ctx, r.table.span, "foreignKeys");
|
|
602
|
+
for (const x of r.columns) feed(ctx, x.span, "foreignKeys");
|
|
603
|
+
return strip(
|
|
604
|
+
{
|
|
605
|
+
name: c.name,
|
|
606
|
+
columns,
|
|
607
|
+
references: target(ctx, r.table),
|
|
608
|
+
refTable: targetName(ctx, r.table),
|
|
609
|
+
refColumns: r.columns.map((x) => columnName(ctx, x)),
|
|
610
|
+
match: r.match,
|
|
611
|
+
onDelete: text(ctx, r.onDelete),
|
|
612
|
+
onUpdate: text(ctx, r.onUpdate),
|
|
613
|
+
notValid: c.notValid,
|
|
614
|
+
notEnforced: c.notEnforced,
|
|
615
|
+
...deferral(c),
|
|
616
|
+
},
|
|
617
|
+
["columns", "refColumns"],
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function exclusionDef(ctx: Ctx, c: ConstraintNode): ExclusionDef {
|
|
622
|
+
return stripUnset({
|
|
623
|
+
name: c.name,
|
|
624
|
+
using: c.using,
|
|
625
|
+
elements: req(text(ctx, c.expr, "exclusions")),
|
|
626
|
+
where: text(ctx, c.where, "exclusions"),
|
|
627
|
+
include: text(ctx, c.include, "exclusions"),
|
|
628
|
+
with: text(ctx, c.with, "exclusions"),
|
|
629
|
+
...deferral(c),
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
interface Commentable {
|
|
634
|
+
comment?: string;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Fold the COMMENT ON statements after the CREATE into the object they name:
|
|
639
|
+
* the object itself, one of its columns, or one of its named constraints.
|
|
640
|
+
* Anything else is refused, since a template declares one object.
|
|
641
|
+
*/
|
|
642
|
+
function applyComments(
|
|
643
|
+
tag: PostgresTag,
|
|
644
|
+
ctx: Ctx,
|
|
645
|
+
comments: readonly CommentNode[],
|
|
646
|
+
self: { schema?: string; name: string },
|
|
647
|
+
objectTypes: readonly string[],
|
|
648
|
+
parts: { columns?: Map<string, Commentable>; constraints?: Map<string, Commentable>; columnComments?: Record<string, string> } = {},
|
|
649
|
+
): string | undefined {
|
|
650
|
+
let comment: string | undefined;
|
|
651
|
+
const isSelf = (q: { schema?: string; name: string }) => q.name === self.name && (q.schema === undefined || self.schema === undefined || q.schema === self.schema);
|
|
652
|
+
const refuse = (c: CommentNode, why: string): never => {
|
|
653
|
+
throw new SqlTemplateError(tag, `COMMENT ON ${c.objectType} ${c.target.pieces.filter(Boolean).join(".") || "${...}"} ${why}`, 0, 0);
|
|
654
|
+
};
|
|
655
|
+
for (const c of comments) {
|
|
656
|
+
const value = c.text ? stringValue(text(ctx, c.text, "comment")) : undefined;
|
|
657
|
+
if (c.objectType === "COLUMN") {
|
|
658
|
+
// `table.column` or `schema.table.column`: the last piece is the column, the rest its relation.
|
|
659
|
+
const all = ctx.tokens.slice(c.target.span.from, c.target.span.to).filter((t) => !isTrivia(t) && !(t.kind === "punct" && t.text === "."));
|
|
660
|
+
const last = all[all.length - 1];
|
|
661
|
+
const col = last === undefined ? "" : last.kind === "ref" ? columnName(ctx, { name: "", span: { from: c.target.span.to - 1, to: c.target.span.to, refs: [] } }) : identValue(last);
|
|
662
|
+
if (all.length < 2) refuse(c, "needs the relation: COMMENT ON COLUMN table.column");
|
|
663
|
+
const owner = qualified(ctx, { pieces: c.target.pieces.slice(0, -1), span: { from: c.target.span.from, to: lastDot(ctx, c.target.span), refs: c.target.span.refs } });
|
|
664
|
+
if (!isSelf(owner)) refuse(c, `is not a column of ${sqlNameOf(self)}`);
|
|
665
|
+
if (parts.columnComments) {
|
|
666
|
+
if (value !== undefined) parts.columnComments[col] = value;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
const column = parts.columns?.get(col);
|
|
670
|
+
if (!column) refuse(c, `names no column of ${sqlNameOf(self)}`);
|
|
671
|
+
if (value !== undefined) column!.comment = value;
|
|
672
|
+
else delete column!.comment;
|
|
673
|
+
} else if (c.objectType === "CONSTRAINT") {
|
|
674
|
+
if (!c.on || !isSelf(qualified(ctx, c.on))) refuse(c, `is not on ${sqlNameOf(self)}`);
|
|
675
|
+
const name = qualified(ctx, c.target).name;
|
|
676
|
+
const constraint = parts.constraints?.get(name);
|
|
677
|
+
if (!constraint) refuse(c, `names no constraint of ${sqlNameOf(self)}; a constraint commented on needs CONSTRAINT ${name} in the definition`);
|
|
678
|
+
if (value !== undefined) constraint!.comment = value;
|
|
679
|
+
} else {
|
|
680
|
+
if (!objectTypes.includes(c.objectType)) refuse(c, `does not comment on the ${tag} this template declares`);
|
|
681
|
+
if (!isSelf(qualified(ctx, c.target))) refuse(c, `names another object than ${sqlNameOf(self)}`);
|
|
682
|
+
comment = value;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return comment;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/** The token index of the last `.` in a span, so `a.b.c` without its last piece is `a.b`. */
|
|
689
|
+
function lastDot(ctx: Ctx, span: Span): number {
|
|
690
|
+
for (let i = span.to - 1; i >= span.from; i--) {
|
|
691
|
+
const t = ctx.tokens[i]!;
|
|
692
|
+
if (t.kind === "punct" && t.text === ".") return i;
|
|
693
|
+
}
|
|
694
|
+
return span.from;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function build(tag: PostgresTag, strings: TemplateStringsArray | readonly string[], values: readonly unknown[]): PostgresObject {
|
|
698
|
+
const parts = templateParts(strings);
|
|
699
|
+
const tokens = spliceWith(POSTGRES_TEMPLATES, tag, parts, values);
|
|
700
|
+
let nodes: StatementNode[];
|
|
701
|
+
try {
|
|
702
|
+
nodes = parseStatements(tokens);
|
|
703
|
+
} catch (err) {
|
|
704
|
+
if (!(err instanceof SqlSyntaxError)) throw err;
|
|
705
|
+
throw templateSyntaxError(tag, parts, err);
|
|
706
|
+
}
|
|
707
|
+
const [node, ...rest] = nodes as [StatementNode, ...StatementNode[]];
|
|
708
|
+
if (node.statement !== STATEMENT_OF[tag]) {
|
|
709
|
+
const holds = STATEMENT_NAMES[node.statement];
|
|
710
|
+
const use = TAG_OF[node.statement];
|
|
711
|
+
throw new SqlTemplateError(tag, use ? `holds a ${holds}; use the ${use} tag` : `holds a ${holds} before any CREATE; a COMMENT ON goes after the CREATE it comments on`, 0, 0);
|
|
712
|
+
}
|
|
713
|
+
const stray = rest.find((n) => n.statement !== "comment");
|
|
714
|
+
if (stray) throw new SqlTemplateError(tag, `holds a second statement (${STATEMENT_NAMES[stray.statement]}); a template declares one object, followed only by COMMENT ON statements for it`, 0, 0);
|
|
715
|
+
const comments = rest as CommentNode[];
|
|
716
|
+
|
|
717
|
+
const positions = regclassPositions(tokens, values);
|
|
718
|
+
const render = (v: unknown, i?: number): string => {
|
|
719
|
+
const at = i === undefined ? undefined : positions.get(i);
|
|
720
|
+
if (at && isPostgresObject(v)) return at === "call" ? `${regclassText(v.sqlName)}::regclass` : regclassText(v.sqlName);
|
|
721
|
+
return renderReference(v);
|
|
722
|
+
};
|
|
723
|
+
const ctx: Ctx = { d: { ...POSTGRES_TEMPLATES, renderReference: render }, tokens, values, fed: values.map(() => new Set<string>()) };
|
|
724
|
+
for (const t of tokens) if (t.splice !== undefined) ctx.fed[t.splice]!.add("ddl");
|
|
725
|
+
const ddl = untokenize(tokens, (i) => render(values[i], i)).trim().replace(/;\s*$/, "");
|
|
726
|
+
const source = { strings: parts };
|
|
727
|
+
const dependsOn = [...new Set(values.filter((v) => isPostgresObject(v) || isColumnRef(v)))];
|
|
728
|
+
const make = <T extends PostgresObject>(type: PostgresEntityType, q: { schema?: string; name: string }, props: object, columnNames?: readonly string[]): T => {
|
|
729
|
+
const entity = makeSqlEntity(PostgresObject.prototype as PostgresObject, type, sqlNameOf(q), props, columnNames, dependsOn) as T;
|
|
730
|
+
setInterpolationFields(entity, ctx.fed.map((paths) => [...paths].sort()));
|
|
731
|
+
return entity;
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
switch (node.statement) {
|
|
735
|
+
case "schema": {
|
|
736
|
+
const q = node.name ? qualified(ctx, node.name) : { name: identValue(req(text(ctx, node.authorization))) };
|
|
737
|
+
if (q.schema !== undefined) throw new SqlTemplateError(tag, `a schema name is not qualified (${sqlNameOf(q)})`, 0, 0);
|
|
738
|
+
const comment = applyComments(tag, ctx, comments, q, ["SCHEMA"]);
|
|
739
|
+
const props: SchemaProps = stripUnset({ name: q.name, ifNotExists: node.ifNotExists, authorization: text(ctx, node.authorization, "authorization"), comment, ddl, source });
|
|
740
|
+
return make(POSTGRES_ENTITY_TYPES.schema, q, props);
|
|
741
|
+
}
|
|
742
|
+
case "extension": {
|
|
743
|
+
const q = qualified(ctx, node.name);
|
|
744
|
+
const comment = applyComments(tag, ctx, comments, { name: q.name }, ["EXTENSION"]);
|
|
745
|
+
const schemaRef = node.schema ? text(ctx, node.schema, "schema") : undefined;
|
|
746
|
+
const props: ExtensionProps = stripUnset({
|
|
747
|
+
name: q.name,
|
|
748
|
+
schema: schemaRef === undefined ? undefined : identValue(schemaRef),
|
|
749
|
+
version: stringValue(text(ctx, node.version, "version")),
|
|
750
|
+
cascade: node.cascade,
|
|
751
|
+
ifNotExists: node.ifNotExists,
|
|
752
|
+
comment,
|
|
753
|
+
ddl,
|
|
754
|
+
source,
|
|
755
|
+
});
|
|
756
|
+
return make(POSTGRES_ENTITY_TYPES.extension, { name: q.name }, props);
|
|
757
|
+
}
|
|
758
|
+
case "enum": {
|
|
759
|
+
const q = qualified(ctx, node.name);
|
|
760
|
+
const comment = applyComments(tag, ctx, comments, q, ["TYPE"]);
|
|
761
|
+
const props: EnumProps = stripUnset({ ...q, labels: node.labels.map((l) => req(stringValue(text(ctx, l, "labels")))), comment, ddl, source });
|
|
762
|
+
return make(POSTGRES_ENTITY_TYPES.enum, q, props);
|
|
763
|
+
}
|
|
764
|
+
case "domain": {
|
|
765
|
+
const q = qualified(ctx, node.name);
|
|
766
|
+
const checks = node.checks.map((c) => stripUnset({ name: c.name, expr: req(text(ctx, c.expr, "checks")), notValid: c.notValid }) as CheckDef);
|
|
767
|
+
const constraints = new Map<string, Commentable>(checks.filter((c) => c.name !== undefined).map((c) => [c.name!, c]));
|
|
768
|
+
const comment = applyComments(tag, ctx, comments.map((c) => (c.objectType === "DOMAIN CONSTRAINT" ? { ...c, objectType: "CONSTRAINT" } : c)), q, ["DOMAIN", "TYPE"], { constraints });
|
|
769
|
+
const props: DomainProps = strip(
|
|
770
|
+
{
|
|
771
|
+
...q,
|
|
772
|
+
dataType: req(text(ctx, node.type, "dataType")),
|
|
773
|
+
collate: text(ctx, node.collate, "collate"),
|
|
774
|
+
default: text(ctx, node.default, "default"),
|
|
775
|
+
notNull: node.notNull,
|
|
776
|
+
checks,
|
|
777
|
+
comment,
|
|
778
|
+
ddl,
|
|
779
|
+
source,
|
|
780
|
+
},
|
|
781
|
+
["checks"],
|
|
782
|
+
);
|
|
783
|
+
return make(POSTGRES_ENTITY_TYPES.domain, q, props);
|
|
784
|
+
}
|
|
785
|
+
case "sequence": {
|
|
786
|
+
const q = qualified(ctx, node.name);
|
|
787
|
+
const comment = applyComments(tag, ctx, comments, q, ["SEQUENCE"]);
|
|
788
|
+
const opt: Partial<SequenceProps> = {};
|
|
789
|
+
for (const o of node.options) {
|
|
790
|
+
const v = text(ctx, o.value, "options");
|
|
791
|
+
switch (o.option) {
|
|
792
|
+
case "AS":
|
|
793
|
+
opt.dataType = v;
|
|
794
|
+
break;
|
|
795
|
+
case "INCREMENT":
|
|
796
|
+
opt.increment = v;
|
|
797
|
+
break;
|
|
798
|
+
case "MINVALUE":
|
|
799
|
+
opt.minValue = v;
|
|
800
|
+
break;
|
|
801
|
+
case "MAXVALUE":
|
|
802
|
+
opt.maxValue = v;
|
|
803
|
+
break;
|
|
804
|
+
case "NO MINVALUE":
|
|
805
|
+
opt.minValue = null;
|
|
806
|
+
break;
|
|
807
|
+
case "NO MAXVALUE":
|
|
808
|
+
opt.maxValue = null;
|
|
809
|
+
break;
|
|
810
|
+
case "START":
|
|
811
|
+
opt.start = v;
|
|
812
|
+
break;
|
|
813
|
+
case "CACHE":
|
|
814
|
+
opt.cache = v;
|
|
815
|
+
break;
|
|
816
|
+
case "CYCLE":
|
|
817
|
+
opt.cycle = true;
|
|
818
|
+
break;
|
|
819
|
+
case "NO CYCLE":
|
|
820
|
+
opt.cycle = false;
|
|
821
|
+
break;
|
|
822
|
+
case "OWNED BY":
|
|
823
|
+
opt.ownedBy = v;
|
|
824
|
+
break;
|
|
825
|
+
case "LOGGED":
|
|
826
|
+
case "UNLOGGED":
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
const props: SequenceProps = { ...stripUnset({ ...q, persistence: node.persistence, ifNotExists: node.ifNotExists }), ...opt, ...stripUnset({ comment, ddl, source }) } as SequenceProps;
|
|
831
|
+
if (opt.cycle === false) props.cycle = false;
|
|
832
|
+
return make(POSTGRES_ENTITY_TYPES.sequence, q, props);
|
|
833
|
+
}
|
|
834
|
+
case "table": {
|
|
835
|
+
const q = qualified(ctx, node.name);
|
|
836
|
+
const columns = node.columns.map((c) => columnDef(ctx, c));
|
|
837
|
+
let primaryKey: KeyDef | undefined;
|
|
838
|
+
const uniques: KeyDef[] = [];
|
|
839
|
+
const checks: CheckDef[] = [];
|
|
840
|
+
const foreignKeys: ForeignKeyDef[] = [];
|
|
841
|
+
const exclusions: ExclusionDef[] = [];
|
|
842
|
+
const file = (c: ConstraintNode, cols: string[]) => {
|
|
843
|
+
if (c.kind === "FOREIGN KEY") foreignKeys.push(foreignKeyDef(ctx, c, cols));
|
|
844
|
+
else if (c.kind === "PRIMARY KEY") {
|
|
845
|
+
if (primaryKey) throw new SqlTemplateError(tag, `${sqlNameOf(q)} declares more than one primary key`, 0, 0);
|
|
846
|
+
primaryKey = keyDef(ctx, c, cols, "primaryKey");
|
|
847
|
+
} else if (c.kind === "UNIQUE") uniques.push(keyDef(ctx, c, cols, "uniques"));
|
|
848
|
+
else if (c.kind === "CHECK") checks.push(checkDef(ctx, c));
|
|
849
|
+
else if (c.kind === "EXCLUDE") exclusions.push(exclusionDef(ctx, c));
|
|
850
|
+
else if (c.kind === "NOT NULL") {
|
|
851
|
+
const col = columns.find((x) => x.name === cols[0]);
|
|
852
|
+
if (!col) throw new SqlTemplateError(tag, `NOT NULL ${cols[0]} names no column of ${sqlNameOf(q)}`, 0, 0);
|
|
853
|
+
col.notNull = true;
|
|
854
|
+
if (c.name) col.notNullName = c.name;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
node.columns.forEach((c, i) => c.constraints.forEach((k) => file(k, [columns[i]!.name])));
|
|
858
|
+
node.constraints.forEach((k) => {
|
|
859
|
+
// Text spliced into a key's column list feeds the key's columns.
|
|
860
|
+
const path = k.kind === "PRIMARY KEY" ? "primaryKey.columns" : k.kind === "UNIQUE" ? "uniques" : k.kind === "FOREIGN KEY" ? "foreignKeys" : undefined;
|
|
861
|
+
if (path) for (const x of k.columns) feed(ctx, x.span, path);
|
|
862
|
+
file(k, k.columns.map((x) => columnName(ctx, x)));
|
|
863
|
+
});
|
|
864
|
+
const named = new Map<string, Commentable>();
|
|
865
|
+
for (const c of [primaryKey, ...uniques, ...checks, ...foreignKeys, ...exclusions]) if (c?.name) named.set(c.name, c);
|
|
866
|
+
const comment = applyComments(tag, ctx, comments, q, ["TABLE"], { columns: new Map(columns.map((c) => [c.name, c])), constraints: named });
|
|
867
|
+
const props: TableProps = strip(
|
|
868
|
+
{
|
|
869
|
+
...q,
|
|
870
|
+
persistence: node.persistence,
|
|
871
|
+
ifNotExists: node.ifNotExists,
|
|
872
|
+
partitionOf: node.partitionOf ? target(ctx, node.partitionOf) : undefined,
|
|
873
|
+
partitionBound: text(ctx, node.partitionBound, "partitionBound"),
|
|
874
|
+
ofType: node.ofType ? target(ctx, node.ofType) : undefined,
|
|
875
|
+
columns,
|
|
876
|
+
primaryKey,
|
|
877
|
+
uniques,
|
|
878
|
+
checks,
|
|
879
|
+
foreignKeys,
|
|
880
|
+
exclusions,
|
|
881
|
+
like: node.like.map((l) => req(text(ctx, l, "like"))),
|
|
882
|
+
inherits: (node.inherits ?? []).map((n) => target(ctx, n)),
|
|
883
|
+
partitionBy: text(ctx, node.partitionBy, "partitionBy"),
|
|
884
|
+
using: text(ctx, node.using, "using"),
|
|
885
|
+
with: text(ctx, node.with, "with"),
|
|
886
|
+
onCommit: text(ctx, node.onCommit),
|
|
887
|
+
tablespace: text(ctx, node.tablespace, "tablespace"),
|
|
888
|
+
comment,
|
|
889
|
+
ddl,
|
|
890
|
+
source,
|
|
891
|
+
},
|
|
892
|
+
["columns", "uniques", "checks", "foreignKeys", "exclusions", "like", "inherits"],
|
|
893
|
+
);
|
|
894
|
+
return make(POSTGRES_ENTITY_TYPES.table, q, props, columns.map((c) => c.name));
|
|
895
|
+
}
|
|
896
|
+
case "index": {
|
|
897
|
+
if (!node.name) {
|
|
898
|
+
throw new SqlTemplateError(tag, "an index needs a name: the name is its identity on the server, and an unnamed index gets a generated one", 0, 0);
|
|
899
|
+
}
|
|
900
|
+
const tableTarget = target(ctx, node.table);
|
|
901
|
+
const tq = qualified(ctx, node.table);
|
|
902
|
+
const name = node.name.pieces[0] || identValue(req(text(ctx, node.name.span)));
|
|
903
|
+
feed(ctx, node.name.span, "name");
|
|
904
|
+
// An index lives in its table's schema.
|
|
905
|
+
const q = { schema: tq.schema, name };
|
|
906
|
+
const comment = applyComments(tag, ctx, comments, q, ["INDEX"]);
|
|
907
|
+
const props: IndexProps = strip(
|
|
908
|
+
{
|
|
909
|
+
...q,
|
|
910
|
+
table: tableTarget,
|
|
911
|
+
tableName: sqlNameOf(tq),
|
|
912
|
+
unique: node.unique,
|
|
913
|
+
concurrently: node.concurrently,
|
|
914
|
+
ifNotExists: node.ifNotExists,
|
|
915
|
+
only: node.only,
|
|
916
|
+
method: node.using,
|
|
917
|
+
elements: node.elements.map((e) => {
|
|
918
|
+
const sig = tokens.slice(e.span.from, e.span.to).filter((t) => !isTrivia(t));
|
|
919
|
+
const ref = sig[0]?.kind === "ref" ? values[sig[0].part] : undefined;
|
|
920
|
+
const byRef = isColumnRef(ref) && sig.slice(1).every((t) => t.kind === "ident" || t.kind === "qident") ? ref.attribute : undefined;
|
|
921
|
+
return stripUnset({ expr: req(text(ctx, e.span, "elements")), column: e.column ?? byRef });
|
|
922
|
+
}),
|
|
923
|
+
include: text(ctx, node.include, "include"),
|
|
924
|
+
nullsNotDistinct: node.nullsNotDistinct,
|
|
925
|
+
with: text(ctx, node.with, "with"),
|
|
926
|
+
tablespace: text(ctx, node.tablespace, "tablespace"),
|
|
927
|
+
where: text(ctx, node.where, "where"),
|
|
928
|
+
comment,
|
|
929
|
+
ddl,
|
|
930
|
+
source,
|
|
931
|
+
},
|
|
932
|
+
["elements"],
|
|
933
|
+
);
|
|
934
|
+
if (node.nullsNotDistinct === false) props.nullsNotDistinct = false;
|
|
935
|
+
return make(POSTGRES_ENTITY_TYPES.index, q, props);
|
|
936
|
+
}
|
|
937
|
+
case "view": {
|
|
938
|
+
const q = qualified(ctx, node.name);
|
|
939
|
+
const lin = lineage<PostgresObject>(ctx, node.query);
|
|
940
|
+
const declared = node.columnNames.map((c) => columnName(ctx, c));
|
|
941
|
+
// A declared column list renames the outputs, by position.
|
|
942
|
+
const edges: LineageEdge[] = lin.edges.map((e, i) => ({ ...e, output: declared[i] ?? e.output }));
|
|
943
|
+
const outputs = declared.length > 0 ? declared : edges.map((e) => e.output);
|
|
944
|
+
const columnComments: Record<string, string> = {};
|
|
945
|
+
const comment = applyComments(tag, ctx, comments, q, node.materialized ? ["MATERIALIZED VIEW"] : ["VIEW"], { columnComments });
|
|
946
|
+
const props: ViewProps = strip(
|
|
947
|
+
{
|
|
948
|
+
...q,
|
|
949
|
+
orReplace: node.orReplace,
|
|
950
|
+
recursive: node.recursive,
|
|
951
|
+
temporary: node.temporary,
|
|
952
|
+
ifNotExists: node.ifNotExists,
|
|
953
|
+
columns: declared,
|
|
954
|
+
with: text(ctx, node.with, "with"),
|
|
955
|
+
using: text(ctx, node.using, "using"),
|
|
956
|
+
tablespace: text(ctx, node.tablespace, "tablespace"),
|
|
957
|
+
query: req(text(ctx, node.query, "query")),
|
|
958
|
+
checkOption: text(ctx, node.checkOption, "checkOption"),
|
|
959
|
+
withData: node.withData,
|
|
960
|
+
reads: lin.reads,
|
|
961
|
+
lineage: edges,
|
|
962
|
+
columnComments: Object.keys(columnComments).length > 0 ? columnComments : undefined,
|
|
963
|
+
comment,
|
|
964
|
+
ddl,
|
|
965
|
+
source,
|
|
966
|
+
},
|
|
967
|
+
["columns", "reads", "lineage"],
|
|
968
|
+
);
|
|
969
|
+
if (node.withData === false) props.withData = false;
|
|
970
|
+
feed(ctx, node.query, "lineage");
|
|
971
|
+
return make(node.materialized ? POSTGRES_ENTITY_TYPES.materializedView : POSTGRES_ENTITY_TYPES.view, q, props, outputs);
|
|
972
|
+
}
|
|
973
|
+
case "comment":
|
|
974
|
+
throw new SqlTemplateError(tag, "a COMMENT ON goes after the CREATE it comments on", 0, 0);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/** `` schema`CREATE SCHEMA ...` ``: one Postgres schema, parsed at build time. */
|
|
979
|
+
export function schema(strings: TemplateStringsArray, ...values: unknown[]): PostgresSchema {
|
|
980
|
+
return build("schema", strings, values) as PostgresSchema;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/** `` table`CREATE TABLE ...` ``: one Postgres table with its columns and constraints, parsed at build time. */
|
|
984
|
+
export function table(strings: TemplateStringsArray, ...values: unknown[]): PostgresTable {
|
|
985
|
+
return build("table", strings, values) as PostgresTable;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** `` index`CREATE [UNIQUE] INDEX [CONCURRENTLY] name ON ...` ``: one named index. */
|
|
989
|
+
export function index(strings: TemplateStringsArray, ...values: unknown[]): PostgresIndex {
|
|
990
|
+
return build("index", strings, values) as PostgresIndex;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/** `` view`CREATE [MATERIALIZED] VIEW ...` ``: one view or materialized view, with what it reads and its column lineage. */
|
|
994
|
+
export function view(strings: TemplateStringsArray, ...values: unknown[]): PostgresView {
|
|
995
|
+
return build("view", strings, values) as PostgresView;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/** `` sequence`CREATE SEQUENCE ...` ``: one sequence. Reference it as `nextval(${seq})`. */
|
|
999
|
+
export function sequence(strings: TemplateStringsArray, ...values: unknown[]): PostgresSequence {
|
|
1000
|
+
return build("sequence", strings, values) as PostgresSequence;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/** `` type`CREATE TYPE name AS ENUM (...)` ``: one enum type. */
|
|
1004
|
+
export function type(strings: TemplateStringsArray, ...values: unknown[]): PostgresEnum {
|
|
1005
|
+
return build("type", strings, values) as PostgresEnum;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/** `` domain`CREATE DOMAIN ...` ``: one domain. */
|
|
1009
|
+
export function domain(strings: TemplateStringsArray, ...values: unknown[]): PostgresDomain {
|
|
1010
|
+
return build("domain", strings, values) as PostgresDomain;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/** `` extension`CREATE EXTENSION ...` ``: one extension. */
|
|
1014
|
+
export function extension(strings: TemplateStringsArray, ...values: unknown[]): PostgresExtension {
|
|
1015
|
+
return build("extension", strings, values) as PostgresExtension;
|
|
1016
|
+
}
|