use crate::schema::Table;
#[derive(Debug, Clone)]
pub struct TableAlias {
pub table: Table,
pub alias: String,
}
impl TableAlias {
pub fn new(table: Table, alias: impl Into<String>) -> Self {
Self {
table,
alias: alias.into(),
}
}
pub fn alias(&self) -> &str {
&self.alias
}
pub fn table(&self) -> &Table {
&self.table
}
}
pub trait TableExt {
fn alias(self, alias: impl Into<String>) -> TableAlias;
}
impl TableExt for Table {
fn alias(self, alias: impl Into<String>) -> TableAlias {
TableAlias::new(self, alias)
}
}