@@ -1028,7 +1028,7 @@ impl Parser {
1028
1028
}
1029
1029
1030
1030
/// Parse one or more identifiers with the specified separator between them
1031
- pub fn parse_compound_identifier ( & mut self , separator : & Token ) -> Result < ASTNode , ParserError > {
1031
+ pub fn parse_list_of_ids ( & mut self , separator : & Token ) -> Result < Vec < SQLIdent > , ParserError > {
1032
1032
let mut idents = vec ! [ ] ;
1033
1033
let mut expect_identifier = true ;
1034
1034
loop {
@@ -1056,27 +1056,19 @@ impl Parser {
1056
1056
self . peek_token( )
1057
1057
) )
1058
1058
} else {
1059
- Ok ( ASTNode :: SQLCompoundIdentifier ( idents) )
1059
+ Ok ( idents)
1060
1060
}
1061
1061
}
1062
1062
1063
1063
/// Parse a possibly qualified, possibly quoted identifier, e.g.
1064
1064
/// `foo` or `myschema."table"`
1065
1065
pub fn parse_object_name ( & mut self ) -> Result < SQLObjectName , ParserError > {
1066
- let identifier = self . parse_compound_identifier ( & Token :: Period ) ?;
1067
- match identifier {
1068
- // TODO: should store the compound identifier itself
1069
- ASTNode :: SQLCompoundIdentifier ( idents) => Ok ( SQLObjectName ( idents) ) ,
1070
- other => parser_err ! ( format!( "Expecting compound identifier, found: {:?}" , other) ) ,
1071
- }
1066
+ Ok ( SQLObjectName ( self . parse_list_of_ids ( & Token :: Period ) ?) )
1072
1067
}
1073
1068
1069
+ /// Parse a comma-separated list of unqualified, possibly quoted identifiers
1074
1070
pub fn parse_column_names ( & mut self ) -> Result < Vec < SQLIdent > , ParserError > {
1075
- let identifier = self . parse_compound_identifier ( & Token :: Comma ) ?;
1076
- match identifier {
1077
- ASTNode :: SQLCompoundIdentifier ( idents) => Ok ( idents) ,
1078
- other => parser_err ! ( format!( "Expecting compound identifier, found: {:?}" , other) ) ,
1079
- }
1071
+ Ok ( self . parse_list_of_ids ( & Token :: Comma ) ?)
1080
1072
}
1081
1073
1082
1074
pub fn parse_precision ( & mut self ) -> Result < usize , ParserError > {
@@ -1194,7 +1186,7 @@ impl Parser {
1194
1186
self . expect_token ( & Token :: RParen ) ?;
1195
1187
ASTNode :: SQLSubquery ( subquery)
1196
1188
} else {
1197
- self . parse_compound_identifier ( & Token :: Period ) ?
1189
+ ASTNode :: SQLCompoundIdentifier ( self . parse_object_name ( ) ? . 0 )
1198
1190
} ;
1199
1191
let alias = self . parse_optional_alias ( keywords:: RESERVED_FOR_TABLE_ALIAS ) ?;
1200
1192
Ok ( ASTNode :: TableFactor {
0 commit comments