durcno@1.0.0-alpha.37
Major Changes
-
4a08ea4 - Thanks to @almahdi404 !
change(columns)!: remove default on delete action for references
Column-level
.references()no longer adds an implicitON DELETE CASCADE. A plain reference now produces noON DELETEclause, so PostgreSQL'sNO ACTIONdefault applies.The object form
.references({ column, onDelete })is removed. Use the lazy getter and chain the delete action instead:userId: bigint({ notNull }).references(() => Users.id),ownerId: bigint({ notNull }).references(() => Users.id).onDeleteCascade(),reviewerId: bigint({}).references(() => Users.id).onDeleteSetNull(),Available actions are
.onDelete(action),.onDeleteCascade(),.onDeleteSetNull(),.onDeleteSetDefault(),.onDeleteRestrict(), and.onDeleteNoAction(). The table-levelfk()builder follows the same rule and emits noON DELETEclause by default.Existing schemas that relied on the implicit
CASCADE— on column-level references or table-level foreign keys — must add.onDeleteCascade(). Without it, the nextgeneraterun emits a migration that replaces those foreign keys withNO ACTION.
Minor Changes
-
e47bc5d - Thanks to @almahdi404 !
feat: accept boolean literals as filter expressions
Boolean literals are now valid wherever a filter expression is expected and render as the PostgreSQL constants
TRUE/FALSE. This works inSELECT,UPDATE, andDELETEwhereclauses,having, joinon, upsertDO UPDATE ... WHERE, aggregatefilter,caseWhen, relationalwhere, query shortcuts, check constraints, and partial index predicates.await db.from(Users).select("*").where(() => true);const filter = and(input.status ? eq(Orders.status, input.status) : true,);count(Users.id).filter(false);and()andor()treat booleans like any other condition while continuing to ignorenullandundefinedentries. Boolean conditions contribute no referenced columns, so they do not affect grouped-query inference.Aggregate
.filter()accepts aFilter | booleanunion, so conditional predicates can be passed directly..filter(true)and.filter(false)keep the aggregate's column scope unchanged, while.filter(condition)still widens it with the filter's referenced columns. -
5f905bb - Thanks to @almahdi404 !
feat(qb): support aliased projections in returning
.returning()now accepts aliased projections onINSERT,UPDATE, andDELETE, mirroring.select()projections. Values can be columns of the affected table, non-aggregate scalarSqlFns, or rawSqlexpressions.const [row] = await db.insertInto(Users).values({ username: "jane_doe", type: "user" }).returning({userId: Users.id,name: Users.username,loweredName: lower(Users.username),});// { userId: bigint; name: string; loweredName: string }Alias keys are used in the returned rows and become the CTE column names when a DML query is wrapped with
db.with(...).as(...). Booleantrue/falseinclusion maps and"*"behave as before, and cannot be mixed with aliased expressions in the same object. Aggregate and window expressions are rejected, matching PostgreSQL. Aliased columns stay qualified against the target table inUPDATE ... FROM, so a same-namedFROMcolumn cannot makeRETURNINGambiguous.