Cleanup validation.rs
This commit is contained in:
parent
6000b1f242
commit
9999d67b8f
2 changed files with 134 additions and 95 deletions
|
|
@ -36,6 +36,24 @@ impl TableSchema {
|
|||
self.types[column_position]
|
||||
}
|
||||
|
||||
pub fn get_columns(&self) -> Vec<&ColumnName> {
|
||||
self.column_name_position_mapping.iter().map(|(name, _)| name).collect()
|
||||
}
|
||||
|
||||
pub fn does_column_exist(&self, column_name: &ColumnName) -> bool {
|
||||
self.column_name_position_mapping.contains_left(column_name)
|
||||
}
|
||||
|
||||
pub fn get_column_position(&self, column_name: &ColumnName) -> Option<ColumnPosition> {
|
||||
self.column_name_position_mapping.get_by_left(column_name).copied()
|
||||
}
|
||||
|
||||
pub fn get_type_at(&self, column_name: &ColumnName) -> Option<DbType> {
|
||||
let position = self.get_column_position(column_name)?;
|
||||
self.types.get(position).copied()
|
||||
}
|
||||
|
||||
// TODO: Get rid of this after validation is merged
|
||||
fn get_column(&self, column_name: &ColumnName) -> DbResult<(DbType, ColumnPosition)> {
|
||||
match self.column_name_position_mapping.get_by_left(column_name) {
|
||||
Some(column_position) => match self.types.get(*column_position) {
|
||||
|
|
@ -52,6 +70,7 @@ impl TableSchema {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Get rid of this after validation is merged
|
||||
pub fn column_position_from_column_name(
|
||||
&self,
|
||||
column_name: &ColumnName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue