Enum sea_orm::entity::ActiveValue [−][src]
Expand description
Defines a stateful value used in ActiveModel.
There are three possible state represented by three enum variants.
- ActiveValue::Set: A defined Value actively being set
- ActiveValue::Unchanged: A defined Value remain unchanged
- ActiveValue::NotSet: An undefined Value
The stateful value is useful when constructing UPDATE SQL statement, see an example below.
Examples
use sea_orm::tests_cfg::{cake, fruit};
use sea_orm::{entity::*, query::*, DbBackend};
// The code snipped below does an UPDATE operation on a `ActiveValue`
assert_eq!(
Update::one(fruit::ActiveModel {
id: ActiveValue::set(1),
name: ActiveValue::set("Orange".to_owned()),
cake_id: ActiveValue::not_set(),
})
.build(DbBackend::Postgres)
.to_string(),
r#"UPDATE "fruit" SET "name" = 'Orange' WHERE "fruit"."id" = 1"#
);
Variants
Set(V)
A defined Value actively being set
Unchanged(V)
A defined Value remain unchanged
NotSet
An undefined Value
Implementations
Create an ActiveValue::Set
Check if the ActiveValue is ActiveValue::Set
Create an ActiveValue::Unchanged
Check if the ActiveValue is ActiveValue::Unchanged
Create an ActiveValue::NotSet
Check if the ActiveValue is ActiveValue::NotSet
Get the mutable value an ActiveValue also setting itself to ActiveValue::NotSet
Get an owned value of the ActiveValue
Check is a Value exists or not
Wrap the Value into a ActiveValue<Value>
Trait Implementations
Performs the conversion.
Auto Trait Implementations
impl<V> RefUnwindSafe for ActiveValue<V> where
V: RefUnwindSafe,
impl<V> Send for ActiveValue<V> where
V: Send,
impl<V> Sync for ActiveValue<V> where
V: Sync,
impl<V> Unpin for ActiveValue<V> where
V: Unpin,
impl<V> UnwindSafe for ActiveValue<V> where
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more