pub struct ChangeExecutor;Expand description
Executes INSERT/UPDATE/DELETE for tracked entities within a transaction.
Implementations§
Source§impl ChangeExecutor
impl ChangeExecutor
Sourcepub async fn execute_inserts<E, F>(
conn: &mut dyn IAsyncConnection,
provider: &dyn IDatabaseProvider,
entities: &[(&E, &EntityTypeMeta)],
on_key_backfill: F,
) -> EFResult<usize>
pub async fn execute_inserts<E, F>( conn: &mut dyn IAsyncConnection, provider: &dyn IDatabaseProvider, entities: &[(&E, &EntityTypeMeta)], on_key_backfill: F, ) -> EFResult<usize>
Executes INSERT statements for all added entities.
Rows are batched into multi-value INSERT INTO ... VALUES (...), (...)
statements to minimize round trips. Batches are sized so that the total
parameter count stays ≤ 900 (SQLite’s variable limit is 999; we use a
conservative ceiling that also fits MySQL/PG). Auto-increment columns
are excluded from the column list (the DB assigns them).
on_key_backfill is invoked once per inserted row. In batch mode the
per-row generated key is not available, so 0 is passed as the key
(the callback is currently a no-op in the framework).
Sourcepub async fn execute_updates<E>(
conn: &mut dyn IAsyncConnection,
provider: &dyn IDatabaseProvider,
entities: &[(&E, &EntityTypeMeta, Option<&HashMap<String, DbValue>>)],
query_filter: Option<&BoolExpr>,
) -> EFResult<usize>
pub async fn execute_updates<E>( conn: &mut dyn IAsyncConnection, provider: &dyn IDatabaseProvider, entities: &[(&E, &EntityTypeMeta, Option<&HashMap<String, DbValue>>)], query_filter: Option<&BoolExpr>, ) -> EFResult<usize>
Executes UPDATE statements for all modified entities. Uses original snapshots for optimistic concurrency tokens in the WHERE clause.
When query_filter is Some, the filter (e.g. a tenant-id predicate)
is AND-ed into the WHERE clause so updates cannot cross the filter
boundary (multi-tenant / soft-delete isolation).
Sourcepub async fn execute_deletes<E>(
conn: &mut dyn IAsyncConnection,
provider: &dyn IDatabaseProvider,
entities: &[(&E, &EntityTypeMeta, Option<&HashMap<String, DbValue>>)],
query_filter: Option<&BoolExpr>,
) -> EFResult<usize>where
E: IEntityType + IGetKeyValues,
pub async fn execute_deletes<E>(
conn: &mut dyn IAsyncConnection,
provider: &dyn IDatabaseProvider,
entities: &[(&E, &EntityTypeMeta, Option<&HashMap<String, DbValue>>)],
query_filter: Option<&BoolExpr>,
) -> EFResult<usize>where
E: IEntityType + IGetKeyValues,
Executes DELETE statements for all deleted entities.
When no concurrency tokens are present and the entity has a single-column
primary key, rows are batched into DELETE ... WHERE pk IN (?, ?, ...)
statements (≤900 params per batch) to minimize round trips. Otherwise
(concurrency tokens, composite PK), falls back to per-row DELETE so
optimistic-concurrency checks run on each row.
When query_filter is Some, the filter is AND-ed into the WHERE
clause so deletes cannot cross the filter boundary.