Expand description
Test basic has_many associations without any preloading of associations during query time. All associations are accessed via queries on demand.
Modules§
Functions§
- assign_
existing_ user_ to_ todo - assign_
todo_ that_ already_ has_ user_ on_ create - assign_
todo_ that_ already_ has_ user_ on_ update - assign_
todo_ to_ user_ on_ update_ query - associate_
new_ user_ with_ todo_ on_ update_ query_ via_ creation - associate_
new_ user_ with_ todo_ on_ update_ via_ creation - belongs_
to_ required - crud_
user_ todos - delete_
when_ belongs_ to_ optional - has_
many_ apply_ combinations - Deterministic matrix over batch shapes. For each
(existing, insert, remove)combination, build onestmt::apply([...])carryinginsertnew children plusremovedissociations, then compare the resulting association set against a reference computed in memory. This covers larger batches and more combinations than the targeted tests above without the non-determinism (and sync/async friction) of aproptestrunner. - has_
many_ apply_ empty_ is_ noop stmt::apply([])on a has-many is a no-op: the surface API’s empty Apply loop adds no entry to the assignments map, so the relation field is treated as unchanged. Run alongside a separate scalar change because the engine verifier rejects updates with no assignments at all.- has_
many_ apply_ insert_ and_ remove stmt::apply([insert(..), remove(..)])mixes Insert and Remove on a has-many in one update. Each entry dispatches as its own Mutation: the Insert associates the new child; the Remove dissociates the old one (and for a required FK, deletes it).- has_
many_ apply_ insert_ and_ remove_ nullable_ fk stmt::apply([insert(..), remove(..)])on a has-many with a nullable foreign key. Unlike the required-FK case (which deletes the child), Remove here takes the disassociate-nullify branch: the old todo persists with its FK set to NULL.- has_
many_ apply_ insert_ remove_ same_ item - Inserting and removing the same existing record in one batch honors
entry order.
insert(&t)(associate an existing row) andremove(&t)(dissociate it) both lower to UPDATEs on the same row; the batch sequences its entries so the last-written op wins, instead of the two UPDATEs racing in the dependency graph. - has_
many_ apply_ multiple_ inserts - has_
many_ apply_ multiple_ removes stmt::apply([remove(a), remove(b)])— only disassociations, no Insert.flatten_relation_batchpushes no merged Insert, so both entries dispatch as standalone Disassociate mutations.- has_
many_ apply_ nested - Nested
stmt::apply([apply([..]), ..]). The surface API flattens nested applies into a single flatBatch(the engine never sees nesting), so this must behave identically to the equivalent flat batch. Guards the flattening contract — if nesting ever stopped flattening, the engine’sflatten_relation_batchdispatch would hit itsunreachable!arm. - has_
many_ apply_ remove_ then_ insert stmt::apply([remove(..), insert(..)])— the reverse ofhas_many_apply_insert_and_remove.flatten_relation_batchalways emits the merged Insert first, so the final state is order-independent: the new child is associated and the old one is removed.- has_
many_ apply_ swap_ unique_ required_ fk - Order-sensitive swap: the child has a
#[unique]title and we replace the “X” todo by removing the old one and inserting a fresh “X”. With a required FK,removedeletes the old row (freeing the unique title), so the insert can reuse it — but only if the delete runs first. - has_
many_ apply_ swap_ unique_ with_ extra_ insert - Same unique-title swap, but with an unrelated
insertat the front of the batch.flatten_relation_batchmerges all inserts into one multi-row INSERT, so the unrelated “Y” insert and the swap’s new “X” insert become a single statement. That merged INSERT must still be dispatched after theremove, or the new “X” collides with the old one on the unique constraint — i.e. coalescing inserts must not pull them ahead of removes. - has_
many_ apply_ two_ inserts_ and_ remove stmt::apply([insert(a), insert(b), remove(c)])— multiple inserts merge into one multi-row INSERT, dispatched alongside a separate Remove. Exercises the Insert-merge path plus a sibling disassociate.- has_
many_ update_ remove - Sanity check for plain
update().todos(stmt::remove(..))— noapplyinvolved. With a required FK, Remove deletes the child row. - has_
many_ when_ fk_ is_ composite - has_
many_ when_ fk_ is_ composite_ with_ snippets - scoped_
find_ by_ id - update_
user_ with_ null_ todo_ is_ err