value exprs
This commit is contained in:
parent
824a5cdb43
commit
d298cb129a
25 changed files with 451 additions and 210 deletions
31
squirrel_core/src/table/table_definition.rs
Normal file
31
squirrel_core/src/table/table_definition.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::table::datatypes::Datatype;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct ColumnDefinition {
|
||||
pub name: String,
|
||||
pub data_type: Datatype,
|
||||
pub length: usize, // used for char(n), varchar(n)
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct TableDefinition {
|
||||
pub name: String,
|
||||
pub column_defs: Vec<ColumnDefinition>,
|
||||
}
|
||||
|
||||
impl TableDefinition {
|
||||
pub fn get_byte_size(&self) -> usize {
|
||||
let mut sum: usize = 0;
|
||||
for col_def in self.column_defs.iter() {
|
||||
// TODO HACK FIXME
|
||||
// We should keep track of length
|
||||
// even for built-in datatypes.
|
||||
sum += if col_def.length > 0 {
|
||||
col_def.length
|
||||
} else {
|
||||
1
|
||||
};
|
||||
}
|
||||
sum
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue