Skip to content

Commit ec62db5

Browse files
committed
improve string enclosed identifiers
1 parent ac92852 commit ec62db5

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

sql-cli/src/cursor_aware_parser.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,4 +1042,35 @@ mod tests {
10421042
assert!(result.suggestions.iter().any(|s| s == "Country"),
10431043
"Should suggest Country for partial 'coun'. Got: {:?}", result.suggestions);
10441044
}
1045+
1046+
#[test]
1047+
fn test_order_by_quoted_partial_completion() {
1048+
let parser = CursorAwareParser::new();
1049+
let mut parser = parser;
1050+
parser.update_single_table(
1051+
"customers".to_string(),
1052+
vec![
1053+
"City".to_string(),
1054+
"Company".to_string(),
1055+
"Country".to_string(),
1056+
"Customer Id".to_string(),
1057+
],
1058+
);
1059+
1060+
// Test ORDER BY completion with partial quoted identifier
1061+
let query = r#"select City,Company,Country,"Customer Id" from customers order by City, "Customer"#;
1062+
let result = parser.get_completions(query, query.len());
1063+
1064+
// The partial word should be "Customer
1065+
assert_eq!(result.partial_word, Some("\"Customer".to_string()),
1066+
"Should extract '\"Customer' as partial");
1067+
1068+
// Should suggest "Customer Id" with proper quotes
1069+
assert!(result.suggestions.iter().any(|s| s == "\"Customer Id\""),
1070+
"Should suggest properly quoted 'Customer Id' for partial '\"Customer'. Got: {:?}", result.suggestions);
1071+
1072+
// Should NOT have truncated suggestions like "Customer
1073+
assert!(!result.suggestions.iter().any(|s| s == "\"Customer"),
1074+
"Should not have truncated suggestion '\"Customer'. Got: {:?}", result.suggestions);
1075+
}
10451076
}

sql-cli/src/hybrid_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ impl HybridParser {
122122
}
123123

124124
pub fn debug_tree(&self, query: &str) -> String {
125-
// We now use recursive descent parser, which doesn't have a tree visualization yet
126-
"Recursive descent parser - AST visualization not implemented".to_string()
125+
// Use the AST formatter from recursive_parser
126+
crate::recursive_parser::format_ast_tree(query)
127127
}
128128

129129
pub fn get_detailed_debug_info(&self, query: &str, cursor_pos: usize) -> String {

0 commit comments

Comments
 (0)