mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 15:29:21 +00:00
Consider empty strings as None
This commit is contained in:
parent
505fa5adb3
commit
2807dcbffa
@ -139,11 +139,16 @@ impl<'a> RowResult<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an optional string => Set to None if string is null
|
/// Get an optional string => Set to None if string is null / empty
|
||||||
pub fn get_optional_str(&self, name: &str) -> ResultBoxError<Option<String>> {
|
pub fn get_optional_str(&self, name: &str) -> ResultBoxError<Option<String>> {
|
||||||
match self.is_null(name)? {
|
match self.is_null(name)? {
|
||||||
true => Ok(None),
|
true => Ok(None),
|
||||||
false => Ok(Some(self.get_str(name)?))
|
false => Ok(Some(self.get_str(name)?).map_or(None, |d|{
|
||||||
|
match d.is_empty() {
|
||||||
|
true => None,
|
||||||
|
false => Some(d)
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user