Skip to content

Split the API into /clickhouse and /postgres entries with one table - #21

Merged
Makisuo merged 1 commit into
mainfrom
feat/dialect-entries
Oct 4, 2026
Merged

Makisuo merged 1 commit into
mainfrom
feat/dialect-entries

Conversation

@Makisuo

@Makisuo Makisuo commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Each database now has one import that covers it, drizzle style:

import * as CH from "@maple-dev/effect-orm/clickhouse"
import * as PG from "@maple-dev/effect-orm/postgres"

Each entry exports the whole query builder (from, param, insertInto, unionAll, …) plus that database's column types, functions, table definitions and a compile that defaults to its dialect. Postgres code never imports CH.

Breaking changes

  • Removed entries: the root @maple-dev/effect-orm entry and /types are gone.
  • One way to declare a table: table now carries its DDL. A ClickHouse table takes an engine and keys; a Postgres table takes a primary key, indexes and foreign keys. The plain table(name, columns, { tenantColumn, defaults, computed }) is gone from the public API.
  • Insert typing: which columns an insert may omit or may not write now comes from column(type, options), not from table options.
  • Definers moved: S.defineTable, S.column, S.engine, S.index, S.materializedView and S.ttlAfterDays move to /clickhouse. S.pg.* moves to /postgres. /schema keeps only the tooling: rendering, snapshots and the diff.
  • Postgres generated columns: these are no longer modeled. The removed computed option was the only way to mark one read-only.

New

  • External tables: table(name, { external: true, columns }) declares something the schema does not own: system tables, table functions, subqueries, or tables another tool migrates. It queries like any table, carries no DDL (so generate skips it) and writes its name verbatim as the FROM target.
const Events = CH.table("events", {
  columns: { OrgId: CH.string, At: CH.dateTime64, Status: CH.column(CH.uint16, { default: 200 }) },
  engine: CH.engine.mergeTree(),
  orderBy: ["OrgId", "At"],
})
const Numbers = CH.table("numbers(10)", { external: true, columns: { number: CH.uint64 } })

Docs and checks

  • Docs: all guides, the README and docs/reference.md are rewritten for the two entries.
  • Export catalog check: check-exports-documented now covers both entries.
  • Package check: check-package now checks the new entry points.

Test plan

  • bun run typecheck
  • bun run test: 615 passed, 195 skipped; doc citations, export catalog and doc examples all pass
  • bun run test:package: the packed tarball passes for imports, types, compilation and codecs
  • bun run test:clickhouse against a live server

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Each database gets one import that covers it: the whole query builder
plus that dialect's column types, functions, table DDL and compile.
The root entry and /types are removed.

`table` is now the only way to declare a table, and it carries its DDL
(CH.table with engine and keys, PG.table with primary key, indexes and
foreign keys). The plain table(name, columns, options) is gone from the
public API; insert typing comes from column options. `external: true`
covers what the schema does not own: system tables, table functions,
subqueries and tables another tool migrates. It has no DDL, so generate
skips it.

/schema keeps only the migration tooling. Docs, reference catalog and
checks are updated for both entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c58331d0-1e49-4c0c-b5da-12c898797785
📥 Commits

Reviewing files that changed from the base of the PR and between 080c8ec and 22dd265.

📒 Files selected for processing (72)
  • CHANGELOG.md
  • README.md
  • docs/README.md
  • docs/benchmarking.md
  • docs/database.md
  • docs/decoding-results.md
  • docs/expressions.md
  • docs/extending.md
  • docs/getting-started.md
  • docs/inserts.md
  • docs/joins-and-subqueries.md
  • docs/migrations.md
  • docs/params-and-compilation.md
  • docs/postgres.md
  • docs/queries.md
  • docs/recipes.md
  • docs/reference.md
  • docs/running-queries.md
  • docs/tables-and-types.md
  • docs/tenant-scoping.md
  • docs/testing.md
  • docs/troubleshooting.md
  • docs/unions-and-ctes.md
  • docs/updates-and-deletes.md
  • package.json
  • scripts/check-doc-examples.mjs
  • scripts/check-exports-documented.mjs
  • scripts/check-package.ts
  • src/benchmark/benchmark.test.ts
  • src/ch/any-boundaries.test-d.ts
  • src/ch/any-boundaries.test.ts
  • src/ch/brand.test-d.ts
  • src/ch/brand.test.ts
  • src/ch/dialect.ts
  • src/ch/functions/builtin.ts
  • src/ch/index.ts
  • src/ch/insert.test-d.ts
  • src/ch/insert.test.ts
  • src/ch/table.ts
  • src/clickhouse.ts
  • src/core.ts
  • src/database/database.test-d.ts
  • src/database/database.test.ts
  • src/docs-examples.test.ts
  • src/index.ts
  • src/kit/generate.ts
  • src/kit/graph.test.ts
  • src/kit/kit.test.ts
  • src/migrate/pg-migrate.test.ts
  • src/pg/postgres.test.ts
  • src/postgres.ts
  • src/schema.ts
  • src/schema/define.ts
  • src/schema/entities.ts
  • src/schema/external.test.ts
  • src/schema/pg-define.ts
  • src/schema/pg-schema.test.ts
  • src/schema/schema.test.ts
  • src/types.ts
  • tests/clickhouse-support.ts
  • tests/core-cases.ts
  • tests/database.clickhouse.test.ts
  • tests/deep-builder.clickhouse.test.ts
  • tests/deep-codecs.clickhouse.test.ts
  • tests/dialect-cases.postgres.ts
  • tests/dialect-cases.ts
  • tests/dialect-coverage.test.ts
  • tests/migrate.clickhouse.test.ts
  • tests/package-consumer.mts
  • tests/postgres-support.ts
  • tests/publish-readiness.clickhouse.test.ts
  • tsdown.config.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Makisuo
Makisuo merged commit 955579d into main Oct 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant