Make schema fields private
This commit is contained in:
parent
71d4bd76f0
commit
37f8b7be91
2 changed files with 8 additions and 4 deletions
|
|
@ -11,9 +11,9 @@ use std::collections::HashMap;
|
|||
#[derive(Debug)]
|
||||
pub struct TableSchema {
|
||||
table_name: TableName, // used for descriptive errors
|
||||
pub primary_key: ColumnPosition,
|
||||
pub column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
||||
pub types: Vec<DbType>,
|
||||
primary_key: ColumnPosition,
|
||||
column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
||||
types: Vec<DbType>,
|
||||
}
|
||||
|
||||
pub type TableName = String;
|
||||
|
|
@ -32,6 +32,10 @@ impl TableSchema {
|
|||
&self.table_name
|
||||
}
|
||||
|
||||
pub fn column_type(&self, column_position: ColumnPosition) -> DbType {
|
||||
self.types[column_position]
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ impl Table {
|
|||
let column_name: ColumnName = self
|
||||
.schema
|
||||
.column_name_from_column_position(column_position)?;
|
||||
let type_ = self.schema.types[column_position];
|
||||
let type_ = self.schema.column_type(column_position);
|
||||
Err(Error::ValueDoesNotMatchExpectedType(
|
||||
self.table_name().clone(),
|
||||
column_name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue