Introduce SQLObjectName struct (4.1/4.4)

(To store "A name of a table, view, custom type, etc., possibly
multi-part, i.e. db.schema.obj".)

Before this change

  - some places used `String` for this (these are updated in this commit)

  - while others (notably SQLStatement::SQLDelete::relation, which is
    the reason for this series of commits) relied on
    ASTNode::SQLCompoundIdentifier (which is also backed by a 
    Vec<SQLIdent>, but, as a variant of ASTNode enum, is not convenient
    to use when you know you need that specific variant).
This commit is contained in:
Nickolay Ponomarev 2019-01-30 21:16:31 +03:00
parent 215820ef66
commit 523f086be7
6 changed files with 42 additions and 27 deletions

View file

@ -1060,11 +1060,11 @@ impl Parser {
}
}
pub fn parse_tablename(&mut self) -> Result<String, ParserError> {
pub fn parse_tablename(&mut self) -> Result<SQLObjectName, ParserError> {
let identifier = self.parse_compound_identifier(&Token::Period)?;
match identifier {
// TODO: should store the compound identifier itself
ASTNode::SQLCompoundIdentifier(idents) => Ok(idents.join(".")),
ASTNode::SQLCompoundIdentifier(idents) => Ok(SQLObjectName(idents)),
other => parser_err!(format!("Expecting compound identifier, found: {:?}", other)),
}
}