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
impl<V> ActiveValue<V> where
V: Into<Value>,
impl<V> ActiveValue<V> where
V: Into<Value>,
pub fn set(value: V) -> ActiveValue<V>
pub fn set(value: V) -> ActiveValue<V>
Create an ActiveValue::Set
pub fn is_set(&self) -> bool
pub fn is_set(&self) -> bool
Check if the ActiveValue is ActiveValue::Set
pub fn unchanged(value: V) -> ActiveValue<V>
pub fn unchanged(value: V) -> ActiveValue<V>
Create an ActiveValue::Unchanged
pub fn is_unchanged(&self) -> bool
pub fn is_unchanged(&self) -> bool
Check if the ActiveValue is ActiveValue::Unchanged
pub fn not_set() -> ActiveValue<V>
pub fn not_set() -> ActiveValue<V>
Create an ActiveValue::NotSet
pub fn is_not_set(&self) -> bool
pub fn is_not_set(&self) -> bool
Check if the ActiveValue is ActiveValue::NotSet
pub fn take(&mut self) -> Option<V>
pub fn take(&mut self) -> Option<V>
Get the mutable value an ActiveValue also setting itself to ActiveValue::NotSet
pub fn unwrap(self) -> V
pub fn unwrap(self) -> V
Get an owned value of the ActiveValue
pub fn into_value(self) -> Option<Value>
pub fn into_value(self) -> Option<Value>
Check is a Value exists or not
pub fn into_wrapped_value(self) -> ActiveValue<Value>
pub fn into_wrapped_value(self) -> ActiveValue<Value>
Wrap the Value into a ActiveValue<Value>
Trait Implementations
impl<V> AsRef<V> for ActiveValue<V> where
V: Into<Value>,
impl<V> AsRef<V> for ActiveValue<V> where
V: Into<Value>,
impl<V> Clone for ActiveValue<V> where
V: Clone + Into<Value>,
impl<V> Clone for ActiveValue<V> where
V: Clone + Into<Value>,
fn clone(&self) -> ActiveValue<V>
fn clone(&self) -> ActiveValue<V>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<V> Debug for ActiveValue<V> where
V: Debug + Into<Value>,
impl<V> Debug for ActiveValue<V> where
V: Debug + Into<Value>,
impl<V> Default for ActiveValue<V> where
V: Into<Value>,
impl<V> Default for ActiveValue<V> where
V: Into<Value>,
fn default() -> ActiveValue<V>
fn default() -> ActiveValue<V>
Returns the “default value” for a type. Read more
impl<V> From<ActiveValue<V>> for ActiveValue<Option<V>> where
V: Into<Value> + Nullable,
impl<V> From<ActiveValue<V>> for ActiveValue<Option<V>> where
V: Into<Value> + Nullable,
fn from(value: ActiveValue<V>) -> ActiveValue<Option<V>>
fn from(value: ActiveValue<V>) -> ActiveValue<Option<V>>
Converts to this type from the input type.
impl<V> PartialEq<ActiveValue<V>> for ActiveValue<V> where
V: Into<Value> + PartialEq<V>,
impl<V> PartialEq<ActiveValue<V>> for ActiveValue<V> where
V: Into<Value> + PartialEq<V>,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more