Merge pull request #223 from SeaQL/active-value-api
`ActiveValue::take()` & `ActiveValue::into_value()` without `unwrap()`
This commit is contained in:
commit
edc2e6500d
@ -209,23 +209,23 @@ where
|
|||||||
matches!(self.state, ActiveValueState::Unset)
|
matches!(self.state, ActiveValueState::Unset)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(&mut self) -> V {
|
pub fn take(&mut self) -> Option<V> {
|
||||||
self.state = ActiveValueState::Unset;
|
self.state = ActiveValueState::Unset;
|
||||||
self.value.take().unwrap()
|
self.value.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap(self) -> V {
|
pub fn unwrap(self) -> V {
|
||||||
self.value.unwrap()
|
self.value.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_value(self) -> Value {
|
pub fn into_value(self) -> Option<Value> {
|
||||||
self.value.unwrap().into()
|
self.value.map(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_wrapped_value(self) -> ActiveValue<Value> {
|
pub fn into_wrapped_value(self) -> ActiveValue<Value> {
|
||||||
match self.state {
|
match self.state {
|
||||||
ActiveValueState::Set => ActiveValue::set(self.into_value()),
|
ActiveValueState::Set => ActiveValue::set(self.into_value().unwrap()),
|
||||||
ActiveValueState::Unchanged => ActiveValue::unchanged(self.into_value()),
|
ActiveValueState::Unchanged => ActiveValue::unchanged(self.into_value().unwrap()),
|
||||||
ActiveValueState::Unset => ActiveValue::unset(),
|
ActiveValueState::Unset => ActiveValue::unset(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ where
|
|||||||
}
|
}
|
||||||
if av_has_val {
|
if av_has_val {
|
||||||
columns.push(col);
|
columns.push(col);
|
||||||
values.push(av.into_value());
|
values.push(av.into_value().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.query.columns(columns);
|
self.query.columns(columns);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user