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)]
|
#[derive(Debug)]
|
||||||
pub struct TableSchema {
|
pub struct TableSchema {
|
||||||
table_name: TableName, // used for descriptive errors
|
table_name: TableName, // used for descriptive errors
|
||||||
pub primary_key: ColumnPosition,
|
primary_key: ColumnPosition,
|
||||||
pub column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
||||||
pub types: Vec<DbType>,
|
types: Vec<DbType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TableName = String;
|
pub type TableName = String;
|
||||||
|
|
@ -32,6 +32,10 @@ impl TableSchema {
|
||||||
&self.table_name
|
&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)> {
|
fn get_column(&self, column_name: &ColumnName) -> DbResult<(DbType, ColumnPosition)> {
|
||||||
match self.column_name_position_mapping.get_by_left(column_name) {
|
match self.column_name_position_mapping.get_by_left(column_name) {
|
||||||
Some(column_position) => match self.types.get(*column_position) {
|
Some(column_position) => match self.types.get(*column_position) {
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ impl Table {
|
||||||
let column_name: ColumnName = self
|
let column_name: ColumnName = self
|
||||||
.schema
|
.schema
|
||||||
.column_name_from_column_position(column_position)?;
|
.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(
|
Err(Error::ValueDoesNotMatchExpectedType(
|
||||||
self.table_name().clone(),
|
self.table_name().clone(),
|
||||||
column_name,
|
column_name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue