use crate::prelude::*;
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Clone)]
pub struct Table {
name: String,
alias: Option<String>,
}
impl Table {
pub fn new(name: impl Into<String>) -> Table {
Table {
name: name.into(),
alias: None,
}
}
pub fn with_alias(mut self, alias: impl Into<String>) -> Table {
self.alias = Some(alias.into());
self
}
}
impl Sql for Table {
fn sql(&self, mut s: String, _ctx: &Context) -> Result<String> {
s.push_str(&self.name);
Ok(s)
}
}
impl From<&str> for Table {
fn from(value: &str) -> Self {
Table::new(value)
}
}