Skip to main content

sql_fun_sqlast/sem/create_table/
table_name.rs

1use std::fmt::Display;
2
3use crate::{
4    sem::{AnalysisError, FullName},
5    syn::RangeVar,
6};
7
8/// table name
9#[derive(Debug, Clone, Eq, Hash, PartialEq, serde::Serialize, serde::Deserialize)]
10pub struct TableName(FullName);
11
12impl Display for TableName {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        self.0.fmt(f)
15    }
16}
17
18impl TableName {
19    /// gets name content
20    #[must_use]
21    pub fn full_name(&self) -> &FullName {
22        &self.0
23    }
24}
25
26impl From<FullName> for TableName {
27    fn from(value: FullName) -> Self {
28        Self(value)
29    }
30}
31
32impl TryFrom<RangeVar> for TableName {
33    type Error = AnalysisError;
34
35    fn try_from(value: RangeVar) -> Result<Self, Self::Error> {
36        Ok(Self(FullName::try_from(value)?))
37    }
38}