Enum sea_orm::entity::ActiveValue
source · [−]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
sourceimpl<V> ActiveValue<V> where
V: Into<Value>,
impl<V> ActiveValue<V> where
V: Into<Value>,
sourcepub fn set(value: V) -> Self
pub fn set(value: V) -> Self
Create an ActiveValue::Set
sourcepub fn is_set(&self) -> bool
pub fn is_set(&self) -> bool
Check if the ActiveValue is ActiveValue::Set
sourcepub fn unchanged(value: V) -> Self
pub fn unchanged(value: V) -> Self
Create an ActiveValue::Unchanged
sourcepub fn is_unchanged(&self) -> bool
pub fn is_unchanged(&self) -> bool
Check if the ActiveValue is ActiveValue::Unchanged
sourcepub fn not_set() -> Self
pub fn not_set() -> Self
Create an ActiveValue::NotSet
sourcepub fn is_not_set(&self) -> bool
pub fn is_not_set(&self) -> bool
Check if the ActiveValue is ActiveValue::NotSet
sourcepub 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
sourcepub fn unwrap(self) -> V
pub fn unwrap(self) -> V
Get an owned value of the ActiveValue
sourcepub fn into_value(self) -> Option<Value>
pub fn into_value(self) -> Option<Value>
Check is a Value exists or not
sourcepub fn into_wrapped_value(self) -> ActiveValue<Value>
pub fn into_wrapped_value(self) -> ActiveValue<Value>
Wrap the Value into a ActiveValue<Value>
Trait Implementations
sourceimpl<V> AsRef<V> for ActiveValue<V> where
V: Into<Value>,
impl<V> AsRef<V> for ActiveValue<V> where
V: Into<Value>,
sourceimpl<V: Clone> Clone for ActiveValue<V> where
V: Into<Value>,
impl<V: Clone> Clone for ActiveValue<V> where
V: Into<Value>,
sourcefn 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
sourceimpl<V> Default for ActiveValue<V> where
V: Into<Value>,
impl<V> Default for ActiveValue<V> where
V: Into<Value>,
sourceimpl<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,
sourcefn from(value: ActiveValue<V>) -> Self
fn from(value: ActiveValue<V>) -> Self
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub 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>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToHex for T where
T: AsRef<[u8]>,
impl<T> ToHex for T where
T: AsRef<[u8]>,
sourcepub fn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
pub fn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Lower case
letters are used (e.g. f9b4ca
) Read more
sourcepub fn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
pub fn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Upper case
letters are used (e.g. F9B4CA
) Read more
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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub 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>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more