Repository navigation
Releases: MapleTechLabs/effect-orm
Release list
v0.7.1
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 (adefineFnresult,untypedExpr, an untypeddynamicColumn) 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 aQueryBuilderError(InvalidLiteral).nullis written asNULLand a bigint as its digits, as before.
v0.7.0
Minor Changes
-
8ee504e: A ClickHouse client for Cloudflare Workers and any
fetchruntime, and OpenTelemetry-shaped spans for every statement.@maple-dev/effect-orm/clickhouse-httpis a ClickHouseSqlClientover Effect'sHttpClient, soDatabaseruns where@effect/sql-clickhouse(Node only) cannot. Interrupting a statement aborts its request and sendsKILL QUERYfor itsquery_id; failures carry the sameSqlErrorreasons as Effect's driver; credentials travel in a header;asCommand,withQueryIdandwithSettingswork as there.Databaseopens 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_rowsanderror.type.withQuerySummary(name)names the statements an effect runs.CompiledQuery.collectionis the table a statement targets: a SELECT'sFROMtable, or the table a write changes.
-
6792323:
effect-orm pullwrites table definitions from an existing ClickHouse database, so adopting effect-orm on a database that already has tables no longer means writing everyCH.tableby hand.- It reads the database the config's
driverconnects to and writes oneCH.tableper 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, sogenerate --baselineadopts them and the nextgeneratehas nothing to do. - Column types map to the built-ins that write the same SQL; others become
CH.customwith a fitting schema (UUID,Date,Decimal,Enum8, …) orCH.untyped. Views and non-MergeTree tables are written asexternal: true. Materialized views,SAMPLE BYandEPHEMERALcolumns are listed for review in the file's header. pullis also exported from/kit.
verifyreads a table's sorting and primary keys as declared. It had comparedsystem.tables.sorting_key, which has aVersionedCollapsingMergeTree's version column appended, so such a table always showed drift. - It reads the database the config's
v0.6.2
Patch Changes
- 6bfed00:
ParamEntry,OptionalParamEntry,OptionalParamsandParamsInare exported from every dialect entry point. A package that exports a query with aparam.*, or adefineFnhelper, failedtsc --declarationwith 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 adefineFnhelper, on TypeScript 7 and 5.
v0.6.1
Patch Changes
- 5bb8bb2: Every entry point can be loaded with
require(). The export map offered only animportcondition, so CommonJS code (and CommonJS builds of TypeScript projects) failed withERR_PACKAGE_PATH_NOT_EXPORTED, although the modules themselves load fine through Node'srequire(esm)(Node 20.19+, 22.12+). Each entry now also has adefaultcondition 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 checkrequire()s every entry from the packed tarball.
v0.6.0
Minor Changes
- a379869: Tenant scoping is now opt-in and enforceable.
fromSqlClient/layerSqlClienttakerequireTenantScope: true, which refuses an undeclared"cross-tenant"statement with aTenantScopeViolationdefect. Compiled queries carrycrossTenantDeclaredwhen the opt-out was explicit, and unions, inserts, updates and deletes gain.crossTenant().rawCompiledQuery'stenantScopeis 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;nullableandarraywrap it, and enum arrays decode from the text form drivers send) and a schema object:generatecreates the type before the tables that use it, adds labels withADD VALUE ... BEFORE, renames one behind aconfirm_renamehint, 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'suniqueConstraints, oruniqueinPG.column(named<table>_<column>_uniqueby default), declares anADD CONSTRAINT ... UNIQUEconstraint, diffed as a constraint rather than an index.verifyreads enums frompg_enumand unique constraints frompg_constraint, and resolves types of the current schema during its scratch rebuild, soPG.custom("public.x", ...)enums no longer report false drift.generate --baseline --from-drizzleconverts drizzle-kit enums, enum columns and unique constraints.
Patch Changes
- 852429b: A concrete insert is assignable to
Runnable(from/database) and accepted bycompileunder TypeScript 5.x again. Both tookCHInsert<any, ...>, which TypeScript 5 compares method by method, and the genericonConflictDoUpdatefailed that comparison; they now take an insert by its tag, state and phantom (AnyInsert). A workaround such astype Runnable = Orm.Runnable | { readonly _tag: "CHInsert" }can be removed.
v0.1.0
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.