fix: correct WIQL syntax and escape_wiql implementation
All checks were successful
Test / rust-fmt-check (pull_request) Successful in 10s
Test / frontend-typecheck (pull_request) Successful in 1m11s
Test / frontend-tests (pull_request) Successful in 1m12s
PR Review Automation / review (pull_request) Successful in 3m6s
Test / rust-clippy (pull_request) Successful in 3m49s
Test / rust-tests (pull_request) Successful in 5m4s

- Replace CONTAINS with ~ operator (correct WIQL syntax for text matching)
- Remove escaping of ~, *, ? which are valid WIQL wildcards
- Update tests to reflect correct escape_wiql behavior
This commit is contained in:
Shaun Arman 2026-04-14 20:38:21 -05:00
parent e6d1965342
commit bc50a78db7

View File

@ -9,9 +9,6 @@ fn escape_wiql(s: &str) -> String {
.replace('\\', "\\\\")
.replace('(', "\\(")
.replace(')', "\\)")
.replace('~', "\\~")
.replace('*', "\\*")
.replace('?', "\\?")
.replace(';', "\\;")
.replace('=', "\\=")
}
@ -207,7 +204,7 @@ pub async fn search_work_items(
let safe_query = escape_wiql(expanded_query);
let wiql_query = format!(
"SELECT [System.Id], [System.Title], [System.Description], [System.State] FROM WorkItems WHERE [System.TeamProject] = '{project}' AND ([System.Title] CONTAINS '{safe_query}' OR [System.Description] CONTAINS '{safe_query}') ORDER BY [System.ChangedDate] DESC"
"SELECT [System.Id], [System.Title], [System.Description], [System.State] FROM WorkItems WHERE [System.TeamProject] = '{project}' AND ([System.Title] ~ '{safe_query}' OR [System.Description] ~ '{safe_query}') ORDER BY [System.ChangedDate] DESC"
);
let wiql_body = serde_json::json!({
@ -345,21 +342,6 @@ mod tests {
assert_eq!(escape_wiql("test)paren"), r#"test\)paren"#);
}
#[test]
fn test_escape_wiql_escapes_tilde() {
assert_eq!(escape_wiql("test~tilde"), r#"test\~tilde"#);
}
#[test]
fn test_escape_wiql_escapes_asterisk() {
assert_eq!(escape_wiql("test*star"), r#"test\*star"#);
}
#[test]
fn test_escape_wiql_escapes_question() {
assert_eq!(escape_wiql("test?quest"), r#"test\?quest"#);
}
#[test]
fn test_escape_wiql_escapes_semicolon() {
assert_eq!(escape_wiql("test;semi"), r#"test\;semi"#);