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

Function parse_return

nodedb/src/engine/graph/pattern/compiler/clauses.rs:100–137  ·  view source on GitHub ↗

Parse RETURN columns.

(text: &str)

Source from the content-addressed store, hash-verified

98
99/// Parse RETURN columns.
100pub(super) fn parse_return(text: &str) -> (Vec<ReturnColumn>, bool) {
101 let trimmed = text.trim();
102 if trimmed.is_empty() || trimmed == "*" {
103 return (Vec::new(), false);
104 }
105
106 // Strip DISTINCT keyword.
107 let (effective, distinct) = {
108 let upper = trimmed.to_uppercase();
109 if upper.starts_with("DISTINCT ") {
110 (&trimmed[9..], true)
111 } else {
112 (trimmed, false)
113 }
114 };
115
116 let columns = split_top_level_commas(effective)
117 .into_iter()
118 .map(|col| {
119 let col = col.trim();
120 let upper = col.to_uppercase();
121 if let Some(as_pos) = upper.rfind(" AS ") {
122 let expr = col[..as_pos].trim().to_string();
123 let alias = col[as_pos + 4..].trim().to_string();
124 ReturnColumn {
125 expr,
126 alias: Some(alias),
127 }
128 } else {
129 ReturnColumn {
130 expr: col.to_string(),
131 alias: None,
132 }
133 }
134 })
135 .collect();
136 (columns, distinct)
137}
138
139/// Parse ORDER BY columns.
140pub(super) fn parse_order_by(text: &str) -> Vec<OrderByColumn> {

Callers 1

parseFunction · 0.70

Calls 4

collectMethod · 0.80
to_stringMethod · 0.80
split_top_level_commasFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected