Skip to main content

ChangeExecutor

Struct ChangeExecutor 

Source
pub struct ChangeExecutor;
Expand description

Executes INSERT/UPDATE/DELETE for tracked entities within a transaction.

Implementations§

Source§

impl ChangeExecutor

Source

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).

Source

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).

Source

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>

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.