mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Consider empty strings as None
This commit is contained in:
		@@ -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)
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user