Ported from ditojs/objection
ditojs/objection is the fork of objection.js by Jürg Lehni, one of its maintainers, and is published as the objection package on npm. Many of its fixes apply to this fork too, so they are ported here, adapted to this fork's code, with credit to their authors in each commit. MySQL and MariaDB fixes come first; fixes that only matter on other databases may not be ported.
Each row links the original commits, which are by Jürg Lehni unless another author is named next to the commit. Each ported commit in this repository has a Co-authored-by line for its original author. The version is the first release of this package with the change.
Bug fixes
| Version | Change | Commits |
|---|---|---|
| 4.1.1 | MySQL: patch() and delete() with a subquery of the same table inside a where group or a join clause failed with ER_UPDATE_TABLE_USED. | d2fea7b8 |
| 4.1.1 | MySQL: delete().orderBy().limit() warns. knex leaves the order out of MySQL deletes, so the limit deletes any of the matching rows. It will throw in 5.0. | 58d14e72 |
| 4.1.1 | insert().onConflict().ignore(): MySQL gave ignored models the id 0, PostgreSQL and SQLite merged the returned rows into the wrong models, and insertAndFetch() tried to fetch ignored models. | ab44f38f |
| 4.1.1 | insertGraph() and upsertGraph() with relate: HasMany and HasOne children whose composite id contains the foreign key were dropped. | b5233df4, df779dfb |
| 4.1.1 | upsertGraph() with cyclic references rejected, but its deletes still ran afterwards. | 3e0c4823 |
| 4.1.1 | A failed graph insert or upsert rejected before its running queries finished, so they could commit rows after the rollback. | f887d7ab |
| 4.1.1 | through.modify of many-to-many relations was lost on bindKnex() classes, so unrelate() deleted join rows that the filter protects. | e94e9296 |
| 4.1.1 | BelongsToOne unrelate() ignored the relation's modify without a where clause, and cleared the keys of owner models it didn't unrelate. | 38356a57, 5a257909 |
| 4.1.1 | Executing a patchAndFetch() or updateAndFetch() query a second time wrote the row fetched by the first run back. It now throws. | d1c8fbef |
| 4.1.1 | A patch() or merge() with a field expression like 'meta:color' wrote nothing when the query was built before it ran, e.g. by toKnexQuery() or a clone. | a1d1877d |
| 4.1.1 | Models returned by upsertGraph() kept leaving out their unchanged props, so a later $query().patch() skipped them. | 0d0e4925 |
| 4.1.1 | A raw() set on a JSON attribute in $beforeInsert() or $beforeUpdate() was stored as the serialized raw builder. | 2e32222f |
| 4.1.1 | withGraphJoined() with a model without a primary key merged rows or gave children the wrong owner. It now throws. | 0963fb9b |
| 4.1.1 | upsertGraph() with relate and noUpdate didn't write the foreign keys of related HasMany and HasOne models. | 638abca1 |
| 4.1.1 | BelongsToOne $relatedQuery().insertGraph() didn't relate the inserted model to the owner. | 97f9d652 |
| 4.1.1 | noInsert still inserted the models below the skipped ones, as orphans. | aea640de |
| 4.1.1 | upsertGraph() with noUpdate, noDelete, noUnrelate and insertMissing ran as an insert and failed with a UniqueViolationError. | b1c87661 |
| 4.1.1 | Patch validation: boolean subschemas, not, nullable and untyped objects, anyOf/oneOf options with only required, and $defs. | e2078f63, 618edca5, 15059556, 65f924d0, 705b92e7 (Jérémy Lal), 6dc8ea89 |
| 4.1.4 | Many-to-many unrelate() and patches with join table extras only modify the join rows that match the filters, also on MySQL. This fork's MySQL code differs: it uses the correlated subquery too, and only fetches the ids first when the filters read the join table or a trigger conflicts. | b3881923, bf2c0a89, 6197ef3c, 038ac35e, 8a4bb58f, 7c526093 (Marcin L, MySQL triggers) |
| 4.1.4 | upsertGraph() patches many-to-many rows by their ids. | 0d4d4c71 |
| 4.1.4 | resolve() in a hook doesn't patch join rows, update instances or clear BelongsToOne owner keys. | ebeba06a |
| 4.1.4 | whereInComposite() with an empty list of composite values. | 495ebb00 |
| 4.2.0 | static useAfterFindInGraphs: eager loading respects the static afterFind() hook of related model classes, opt-in in 4.x. | 70b2417d, c1433500 |