durcno@1.0.0-alpha.18
Minor Changes
-
fe4d888 - Thanks to @almahdi404 !
feat(select): add groupBy and having clauses
SelectQuerynow supports explicitGROUP BYandHAVINGclauses via.groupBy()and.having()methods..groupBy()accepts a column, a scalarSqlFn, or an array of either. It also supports a callback form that lets you reference named aliases from your.select({...})map — useful when grouping by computed expressions..having()filters grouped results using aggregate expressions. Comparison filters (eq,ne,gt,gte,lt,lte) were extended to accept aggregateSqlFnoperands, enabling aggregate-to-literal and aggregate-to-aggregate comparisons.// Direct formconst result = await db.from(Users).select({ type: Users.type, total: count("*") }).groupBy(Users.type).having(gte(count("*"), 5));// Callback form — reference select aliasesconst result2 = await db.from(Users).select({ lname: lower(Users.username), total: count("*") }).groupBy(({ lname }) => [lname]);Both methods are one-time — calling
.groupBy()or.having()a second time is a compile-time error. Aggregate functions are rejected by the type system asGROUP BYoperands (only scalar expressions and columns are valid).
Patch Changes
-
f99cb38 - Thanks to @almahdi404 !
fix(rq/types): use explicit return type in .findFirst
Use an explicit return type for
findFirstinRelationQueryBuilderso nested relation queries preserve their inferred result shape. Added a type-level annotation and coverage for a 3-level nested relation query (Posts→comments→author). -
2bedca0 - Thanks to @almahdi404 !
fix(migration/ddl): extract DDLStatement to break recursive import
DDLStatement,DDLStatementType,CustomStatement, andcustomwere previously defined directly insrc/migration/ddl/index.ts. Since other DDL modules (schema.ts,table.ts,types.ts,indexes.ts,sequence.ts) all importedDDLStatementfrom./index, this created a recursive import cycle.The fix extracts these base definitions into a new dedicated file
src/migration/ddl/statement.ts. All DDL modules now importDDLStatementfrom./statement, andindex.tsre-exports everything fromstatement.ts— eliminating the circular dependency.