mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-10 05:52:13 +00:00
Enhance object name path segments (#1539)
This commit is contained in:
parent
fd6c98e933
commit
211b15e790
20 changed files with 584 additions and 466 deletions
|
@ -267,7 +267,13 @@ impl fmt::Display for Ident {
|
|||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct ObjectName(pub Vec<Ident>);
|
||||
pub struct ObjectName(pub Vec<ObjectNamePart>);
|
||||
|
||||
impl From<Vec<Ident>> for ObjectName {
|
||||
fn from(idents: Vec<Ident>) -> Self {
|
||||
ObjectName(idents.into_iter().map(ObjectNamePart::Identifier).collect())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ObjectName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
@ -275,6 +281,30 @@ impl fmt::Display for ObjectName {
|
|||
}
|
||||
}
|
||||
|
||||
/// A single part of an ObjectName
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum ObjectNamePart {
|
||||
Identifier(Ident),
|
||||
}
|
||||
|
||||
impl ObjectNamePart {
|
||||
pub fn as_ident(&self) -> Option<&Ident> {
|
||||
match self {
|
||||
ObjectNamePart::Identifier(ident) => Some(ident),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ObjectNamePart {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
ObjectNamePart::Identifier(ident) => write!(f, "{}", ident),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents an Array Expression, either
|
||||
/// `ARRAY[..]`, or `[..]`
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue