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

Function normalize_object_name_checked

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

Normalize a compound object name, rejecting schema-qualified forms. Accepts a single-part name (plain identifier) and returns it normalized. Rejects any name with more than one part (e.g. `public.users`, `db.public.users`) with `SqlError::Unsupported`.

(name: &sqlparser::ast::ObjectName)

Source from the content-addressed store, hash-verified

24/// Rejects any name with more than one part (e.g. `public.users`,
25/// `db.public.users`) with `SqlError::Unsupported`.
26pub fn normalize_object_name_checked(name: &sqlparser::ast::ObjectName) -> Result<String> {
27 if name.0.len() > 1 {
28 // Build a human-readable representation of what was actually written.
29 let qualified: String = name
30 .0
31 .iter()
32 .map(|part| match part {
33 sqlparser::ast::ObjectNamePart::Identifier(ident) => ident.value.clone(),
34 _ => String::new(),
35 })
36 .collect::<Vec<_>>()
37 .join(".");
38 return Err(SqlError::Unsupported {
39 detail: format!("'{qualified}': {SCHEMA_QUALIFIED_MSG}"),
40 });
41 }
42 Ok(name
43 .0
44 .first()
45 .map(|part| match part {
46 sqlparser::ast::ObjectNamePart::Identifier(ident) => normalize_ident(ident),
47 _ => String::new(),
48 })
49 .unwrap_or_default())
50}
51
52/// Extract table name and optional alias from a table factor.
53///

Callers 15

table_ref_matchesFunction · 0.85
extract_table_nameFunction · 0.85
classify_on_conflictFunction · 0.85
plan_insertFunction · 0.85
plan_upsertFunction · 0.85
plan_merge_sourceFunction · 0.85
merge_source_aliasFunction · 0.85
convert_merge_actionFunction · 0.85
plan_update_fromFunction · 0.85

Calls 6

normalize_identFunction · 0.85
joinMethod · 0.80
firstMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45