Repository navigation
v3.2.0
Objection is now maintained at ditojs/objection.
What's new
- Support mixing
withGraphJoined()andwithGraphFetched()in the same query. Before, the last method called silently decided the algorithm for all relations. A top-level relation can only be loaded with one of them. #2269 - Add
none()to make a query match no rows #2184 upsertGraph(): mark individual related models with#unrelateor#delete#2410- Return rows from
relate()withreturning()#2044 - Apply
select()to the fetch query ofupdateAndFetch(),patchAndFetch()and theirByIdvariants #1938 - Add a
noDoubleUnderscoresoption to the snake case mappers #2805 - Pass
formatoptions fromtoJSON()/$toJson()to$formatJson()of the model and all nested models #2033 - Support
$defsin JSON schemas #2576
Fixes
- Behaviour change: throw when
for()is used outside ofrelatedQuery(). It was silently ignored before, soModel.query().for(1).delete()deleted every row of the table. #2185 - Behaviour change: throw when
for()is called after a write method on arelatedQuery(). Before,update(),patch()anddelete()silently did nothing, andinsert()andrelate()wroteNULLforeign keys. - Fix validators being shared between models with the same
uniqueTag()but different schemas #2540 - Fix
orderBy()with refs and raws as array items #2252 - Clear an
orderByadded at build time, e.g. by a relation'smodify, from theresultSize()andpage()count query #2747 - Support
Model.ref()references in relation join mappings #1873 - Reference the bare column in JSON where methods when no JSON path is given, so Postgres can use GIN indexes #2008
- Fix subqueries in join builders on MySQL (
parentQuery.isUpdate is not a function) #2407 - Make
union()deduplicate regardless of array size #2811 - Serialize relation modifiers and aliases before the recursion marker in
RelationExpression.toString()#2812
Types
- Fix
first()infinite type recursion in custom query builder methods #2637 - Keep nested relation data type-checked when inserting model data interfaces #2190
- Keep custom query builder types after
throwIfNotFound() - Add a
QueryBuilderconstructor typing for custom query builders #2306 - Allow
nulland readonly arrays foridColumn, readonly arrays forjsonAttributes#2693, #2745 - Allow
bigintvalues in where methods #2318 - Support object joins,
limit()/offset()withskipBinding, and aliased aggregates #2189 - Fix
tableNameFor()andtableRefFor()return and argument types #2790 - Add
knexIdentifierMapping#1947 - Add
tableName(),tableRef()andemptyInstance()toQueryBuilder#2792, #2794 - Add the column list overload of
with()#2749 - Fix generic static
thisforquery(),fromJson()andfetchGraph()#2700
Docs
- Document what
afterInsert()receives asresult#2342 - Document that
withGraphJoined()requires a primary key #2748 - Document the
skipUndefined()deprecation #2149 - Use
declarefor the query builder type properties in the custom query builder and plugin recipes, which fail with TS2612 on ES2022+ targets - Fix the koa-ts example typings #2361
- Clarify
whereNotColumn()#2808
Other
- Drop Node 14 from CI. Objection still supports it, but knex 3 requires Node 16+.
Thanks to everyone whose pull requests made it into this release: @amit-meshbey, @androvonx95, @bilalakbar, @Bolt4243, @cesumilo, @falkenhawk, @geeksilva97, @IlyaSemenov, @kapouer, @kartikdp, @LiahMartens, @max-kahnt-keylight, @nickbouldien, @nickfuryoc, @ralcorta and @salisbury-espinosa.