Extract table name and optional alias from a table factor. Returns `Err` if the table name is schema-qualified.
(
factor: &sqlparser::ast::TableFactor,
)
| 53 | /// |
| 54 | /// Returns `Err` if the table name is schema-qualified. |
| 55 | pub fn table_name_from_factor( |
| 56 | factor: &sqlparser::ast::TableFactor, |
| 57 | ) -> Result<Option<(String, Option<String>)>> { |
| 58 | match factor { |
| 59 | sqlparser::ast::TableFactor::Table { name, alias, .. } => { |
| 60 | let table = normalize_object_name_checked(name)?; |
| 61 | let alias_name = alias.as_ref().map(|a| normalize_ident(&a.name)); |
| 62 | Ok(Some((table, alias_name))) |
| 63 | } |
| 64 | _ => Ok(None), |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | #[cfg(test)] |
| 69 | mod tests { |
no test coverage detected