ORM-14: Ambient Query terminals and a single hydrate path #14
Labels
No labels
area:core
area:database
area:migrations
area:model
area:relations
area:schema
area:tests
breaking-change
size:M
size:S
tracking
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
NoctisWolfshadow/tessera-orm#14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on: #4, #6
Context
Queries should run against the ambient connection (
User::query().all()), with an_on(&Connection)escape hatch. Every row loaded from the database must also get itsModelStatesnapshot, so there must be exactly one place where rows become models. Relations will reuse it.Tasks
Query::all() -> Result<Vec<M>>andQuery::first() -> Result<Option<M>>run throughDatabase::with.all_on(&Connection)andfirst_on(&Connection).hydrate::<M>(row)that callsM::from_rowand then snapshots withstate_mut().snapshot(model.insert_values()). All read paths use it..all(&conn)becomes.all_on(&conn)) so the suite stays green. #17 does the full port.Example
Acceptance criteria
all,firstandall_onreportstate().is_persisted()._onrename.insert,update,delete,create,findandalltoModel#15load_for) to avoid N+1 queries #23