Skip to content

Releases: MapleTechLabs/effect-orm

v0.7.1

Choose a tag to compare

@github-actions github-actions released this 21 Oct 14:44
d83fc66

Patch Changes

  • 8e74459: Refuse values with no SQL literal instead of writing String(value). A value compared against, or passed to, an expression with no column type (a defineFn result, untypedExpr, an untyped dynamicColumn) used to be written raw when it was not a string, number, boolean or date: an array or object from a request became part of the SQL (toFloat64OrNull(x) > 1) OR (1=1). It now fails compilation with a QueryBuilderError (InvalidLiteral). null is written as NULL and a bigint as its digits, as before.

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 21:39
9fa64f6

Minor Changes

  • 8ee504e: A ClickHouse client for Cloudflare Workers and any fetch runtime, and OpenTelemetry-shaped spans for every statement.

    • @maple-dev/effect-orm/clickhouse-http is a ClickHouse SqlClient over Effect's HttpClient, so Database runs where @effect/sql-clickhouse (Node only) cannot. Interrupting a statement aborts its request and sends KILL QUERY for its query_id; failures carry the same SqlError reasons as Effect's driver; credentials travel in a header; asCommand, withQueryId and withSettings work as there.
    • Database opens one client span per statement, named and attributed per the OpenTelemetry database conventions: db.system.name, db.operation.name, db.collection.name, db.query.summary, db.response.returned_rows and error.type. withQuerySummary(name) names the statements an effect runs.
    • CompiledQuery.collection is the table a statement targets: a SELECT's FROM table, or the table a write changes.
  • 6792323: effect-orm pull writes table definitions from an existing ClickHouse database, so adopting effect-orm on a database that already has tables no longer means writing every CH.table by hand.

    • It reads the database the config's driver connects to and writes one CH.table per table: engine and arguments, keys as declared, partition key, TTL, settings, comments, column defaults, codecs and skipping indexes. The definitions yield exactly what the database holds, so generate --baseline adopts them and the next generate has nothing to do.
    • Column types map to the built-ins that write the same SQL; others become CH.custom with a fitting schema (UUID, Date, Decimal, Enum8, …) or CH.untyped. Views and non-MergeTree tables are written as external: true. Materialized views, SAMPLE BY and EPHEMERAL columns are listed for review in the file's header.
    • pull is also exported from /kit.

    verify reads a table's sorting and primary keys as declared. It had compared system.tables.sorting_key, which has a VersionedCollapsingMergeTree's version column appended, so such a table always showed drift.

v0.6.2

Choose a tag to compare

@github-actions github-actions released this 14 Oct 22:47
28ad10b

Patch Changes

  • 6bfed00: ParamEntry, OptionalParamEntry, OptionalParams and ParamsIn are exported from every dialect entry point. A package that exports a query with a param.*, or a defineFn helper, failed tsc --declaration with TS4023 / TS2742: their types name these, and tsc could only reach them through a hashed internal chunk. The package-consumer check now emits declarations for exported queries with plain, optional (when / whenTrue) and union-named params, joins, CTEs, subqueries, unions and a defineFn helper, on TypeScript 7 and 5.

v0.6.1

Choose a tag to compare

@github-actions github-actions released this 14 Oct 11:01
ec0a12f

Patch Changes

  • 5bb8bb2: Every entry point can be loaded with require(). The export map offered only an import condition, so CommonJS code (and CommonJS builds of TypeScript projects) failed with ERR_PACKAGE_PATH_NOT_EXPORTED, although the modules themselves load fine through Node's require(esm) (Node 20.19+, 22.12+). Each entry now also has a default condition pointing at the same .mjs, so a CommonJS caller loads the very module an ES module caller does, and shares its Effect. The package-consumer check require()s every entry from the packed tarball.

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 13 Oct 00:01
0623054

Minor Changes

  • a379869: Tenant scoping is now opt-in and enforceable. fromSqlClient / layerSqlClient take requireTenantScope: true, which refuses an undeclared "cross-tenant" statement with a TenantScopeViolation defect. Compiled queries carry crossTenantDeclared when the opt-out was explicit, and unions, inserts, updates and deletes gain .crossTenant(). rawCompiledQuery's tenantScope is now optional and defaults to "cross-tenant".
  • e26a29d: Postgres enum types and unique constraints are first-class. PG.enumType(name, labels, { schema? }) is a column type (rows decode to its labels; inserts and comparisons take only them; nullable and array wrap it, and enum arrays decode from the text form drivers send) and a schema object: generate creates the type before the tables that use it, adds labels with ADD VALUE ... BEFORE, renames one behind a confirm_rename hint, asks before dropping the type, and reports removing or reordering labels, or using a label in the migration that adds it, as unsupported. PG.unique(name, columns, { nullsNotDistinct? }) in a table's uniqueConstraints, or unique in PG.column (named <table>_<column>_unique by default), declares an ADD CONSTRAINT ... UNIQUE constraint, diffed as a constraint rather than an index. verify reads enums from pg_enum and unique constraints from pg_constraint, and resolves types of the current schema during its scratch rebuild, so PG.custom("public.x", ...) enums no longer report false drift. generate --baseline --from-drizzle converts drizzle-kit enums, enum columns and unique constraints.

Patch Changes

  • 852429b: A concrete insert is assignable to Runnable (from /database) and accepted by compile under TypeScript 5.x again. Both took CHInsert<any, ...>, which TypeScript 5 compares method by method, and the generic onConflictDoUpdate failed that comparison; they now take an insert by its tag, state and phantom (AnyInsert). A workaround such as type Runnable = Orm.Runnable | { readonly _tag: "CHInsert" } can be removed.

v0.1.0

Choose a tag to compare

@Makisuo Makisuo released this 08 Sep 22:10

Standalone extraction of @maple-dev/effect-clickhouse from Maple.

Includes the ClickHouse DSL, SQL helpers, benchmark API and CLI, documentation, MIT license, and built ESM/type declarations.

Install the attached npm-compatible tarball with Effect 4.0.0-rc.112. npm registry publication is pending.

Validation: 398 tests passed against local ClickHouse, typechecks, documentation checks, and isolated npm/Node consumer checks. CI verifies ClickHouse 26.2.19.43 and 26.8.2.7.