MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / table_name_from_factor

Function table_name_from_factor

nodedb-sql/src/parser/normalize.rs:55–66  ·  view source on GitHub ↗

Extract table name and optional alias from a table factor. Returns `Err` if the table name is schema-qualified.

(
    factor: &sqlparser::ast::TableFactor,
)

Source from the content-addressed store, hash-verified

53///
54/// Returns `Err` if the table name is schema-qualified.
55pub 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)]
69mod tests {

Callers 3

scan_for_relationFunction · 0.85
plan_selectFunction · 0.85
resolve_table_factorMethod · 0.85

Calls 3

normalize_identFunction · 0.85
as_refMethod · 0.45

Tested by

no test coverage detected