durcno@1.0.0-alpha.11
Minor Changes
-
536cce6 - Thanks to @almahdi404 !
fix(columns/validators): correct type inference for nullable columns in insert and update
Fixed incorrect TypeScript type inference for nullable columns across
ValTypeInsert,ValTypeUpdate, andValTypeSelectinColumn, as well as the Zod insert/update schema generators.ValTypeInsertnow correctly marks nullable columns asValType | Sql | null | undefined(optional with null), andnotNullcolumns without a default asValType | Sql(required, no null).ValTypeUpdatenow consistently returnsValType | undefinedfornotNullcolumns andValType | undefined | nullfor nullable ones. TheUpdateBuilder.set()method excludesundefinedfrom accepted values so that partial updates remain type-safe.ValTypeSelectlogic was simplified to usethis extends ...structural checks instead ofTConfig extends ..., avoiding edge-cases with config-level vs runtime-resolved column traits.Zod schemas (
createInsertSchema/createUpdateSchema) were updated to match:- Nullable columns →
zodSchema.nullable().optional() notNullcolumns with a default or insert function →zodSchema.optional()notNullcolumns with no default →zodSchema(required)
Also fixed a subtle bug in array-dimension tuple schema generation where
Array(n).map(...)was replaced withArray.from({ length: n }, ...)to avoid iterating over sparse arrays. - Nullable columns →
Patch Changes
-
b5382ef - Thanks to @almahdi404 !
fix: properly handle rq nested relation order by
Fixed orderBy clauses in nested relations (many-to-one queries) not properly resolving table aliases. The issue occurred when using orderBy within
optionsof nested relation queries, where column references couldn't be correctly mapped to their table aliases.Changes include:
- Updated
Order.toQuery()andOrderSqlFn.toQuery()methods to accept optionalQueryContextparameter for proper alias resolution - Modified nested relation subquery building to pass table alias context through orderBy operations
Now orderBy works correctly in nested relation queries like:
db.from(Users).relational({posts: {orderBy: [desc(Posts.createdAt)],limit: 5,},}); - Updated