Struct rustorm::table::Table [] [src]

pub struct Table {
    pub schema: String,
    pub name: String,
    pub parent_table: Option<String>,
    pub sub_table: Vec<String>,
    pub comment: Option<String>,
    pub columns: Vec<Column>,
    pub is_view: bool,
}

Fields

schema

which schema this belongs

name

the table name

parent_table

the parent table of this table when inheriting (>= postgresql 9.3) [FIXME] need to tell which schema this parent table belongs there might be same table in different schemas

sub_table

what are the other table that inherits this [FIXME] need to tell which schema this parent table belongs there might be same table in different schemas

comment

comment of this table

columns

columns of this table

is_view

views can also be generated

Methods

impl Table

fn complete_name(&self) -> String

return the long name of the table using schema.table_name

fn struct_name(&self) -> String

capitalize the first later, if there is underscore remove it then capitalize the next letter

fn displayname(&self) -> String

get the display name of this table product_availability -> Product Availability

fn condensed_displayname(&self, table: &Table) -> String

get a shorter display name of a certain table when being refered to this table example product.product_availability -> Availability user.user_info -> Info

fn condensed_member_name(&self, used_in_table: &Table) -> String

get a condensed name of this table when used in contex with another table

fn has_column_name(&self, column: &str) -> bool

determine if this table has a colum named

fn get_column(&self, column: &str) -> Option<Column>

return the column of this table with the name

fn primary_columns(&self) -> Vec<&Column>

return all the primary columns of this table

fn non_nullable_columns(&self) -> Vec<String>

fn uninherited_columns(&self) -> Vec<&Column>

return all the columns of this table excluding the inherited columns

fn inherited_columns(&self) -> Vec<&Column>

return all the inherited columns

fn is_primary(&self, column_name: &str) -> bool

check to see if the column is a primary or not the Column.is_primary property is not reliable since it also list down the foreign key which makes it 2 entries in the table

fn unique_columns(&self) -> Vec<&Column>

return all the unique keys of this table

fn foreign_columns(&self) -> Vec<&Column>

fn get_table<'a>(schema: &str, table_name: &str, tables: &'a Vec<Table>) -> &'a Table

return the first match of table name regardless of which schema it belongs to. get the table definition using the table name from an array of table object [FIXME] Needs to have a more elegant solution by using HashMap

fn referred_tables<'a>(&'a self, tables: &'a Vec<Table>) -> Vec<(&'a Column, &'a Table)>

get all the tables that is referred by this table get has_one

fn referring_tables<'a>(&self, tables: &'a Vec<Table>) -> Vec<(&'a Table, &'a Column)>

has_many_direct get all other tables that is refering to this table when any column of a table refers to this table get_has_many

fn get_all_applicable_reference<'a>(&'a self, all_tables: &'a Vec<Table>) -> Vec<RefTable>

all the referenced table of this table, this is used in building the structs as stubs or final model definitions it does not include the parent is this table is just an extension to it when a linker table, no applicable referenced is returned parent of extension tables are not returned

fn is_linker_table(&self) -> bool

determine if this table is a linker table FIXME: make sure that there are 2 different tables referred to it

fn is_owned(&self, tables: &Vec<Table>) -> bool

determines if the table is owned by some other table say order_line is owned by orders which doesn't make sense to be a stand alone window on its own characteristic: if it has only 1 has_one which is its owning parent table and no other direct or indirect referring table

fn indirect_referring_tables<'a>(&self, tables: &'a Vec<Table>) -> Vec<(&'a Table, &'a Table)>

has many indirect when there is a linker table, bypass the 1:1 relation to the linker table then create a 1:M relation to the other linked table Algorithmn: determine whether a table is a linker then get the other linked table *get all the referring table *for each table that refer to this table *if there are only 2 columns and is both primary and foreign key at the same time and 1 of which refer to the primary column of this table * then the other table that is refered is the indirect referring table returns the table that is indirectly referring to this table and its linker table

fn extension_tables<'a>(&self, tables: &'a Vec<Table>) -> Vec<&'a Table>

get referring tables, and check if primary columns of these referring table is the same set of the primary columns of this table it is just an extension table [FIXED]~~FIXME:~~ 2 primary 1 foreign should not be included as extension table case for photo_sizes

fn is_extension_of(&self, table: &Table, all_tables: &Vec<Table>) -> bool

determines if this table is just an extension of the table specified extension tables need not to contain a reference of their parent table

fn get_foreign_columns_to_table(&self, foreign_table: &Table) -> Vec<&Column>

returns the columns of these table that is a foreign columns to the foreign table

Trait Implementations

impl ToTableName for Table

fn to_table_name(&self) -> TableName

impl Display for Table

fn fmt(&self, f: &mut Formatter) -> Result

impl PartialEq for Table

fn eq(&self, other: &Self) -> bool

fn ne(&self, other: &Self) -> bool

Derived Implementations

impl Debug for Table

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for Table

fn clone(&self) -> Table

fn clone_from(&mut self, source: &Self)