Skip to main content

IGetKeyValues

Trait IGetKeyValues 

Source
pub trait IGetKeyValues: IEntityType {
    // Required method
    fn key_values(&self) -> HashMap<String, DbValue>;

    // Provided methods
    fn set_auto_increment_key(&mut self, _key: i64) { ... }
    fn set_foreign_key(&mut self, _target_type: TypeId, _key: i64) { ... }
}
Expand description

Extracts primary key values from an entity for SaveChanges WHERE clauses.

Auto-generated by #[derive(EntityType)].

Required Methods§

Provided Methods§

Source

fn set_auto_increment_key(&mut self, _key: i64)

Sets the auto-increment primary key after INSERT.

Called by the change executor to backfill database-generated keys into the entity. The default implementation is a no-op (for entities without an auto-increment PK, or for manual implementations that haven’t overridden it). The #[derive(EntityType)] macro overrides this for entities with a single #[auto_increment] #[primary_key] field.

Source

fn set_foreign_key(&mut self, _target_type: TypeId, _key: i64)

Sets the foreign key field pointing to target_type to key.

Called by the cascade save pipeline to fixup child FKs after the principal’s auto-increment PK is backfilled. The default implementation is a no-op. The #[derive(EntityType)] macro overrides this for each #[foreign_key(Target)] scalar field.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§