Skip to content

Commit

Permalink
query2: Support escaped quotes in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-bjareholt committed Mar 17, 2019
1 parent 5b7e677 commit fd09011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ mod lexer {

r#"return"# => (Token::Return, text),

r#"\"[^\"]*\""# => (
Token::String(text.to_owned()[1..text.len()-1].to_string()),
r#"\"([^\"]|(\\\"))*\""# => (
Token::String(text.to_owned()[1..text.len()-1].replace("\\\"", "\"").to_string()),
text
),
r#"[0-9]+[\.]?[0-9]*"# => {
Expand Down
4 changes: 2 additions & 2 deletions tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ mod query_tests {
let ds = setup_datastore_empty();
let interval = TimeInterval::new_from_string(TIME_INTERVAL).unwrap();

let code = String::from("a=\"test\";");
let code = String::from("a=\"test \\\" with escaped quote\";");
let ret = query::query(&code, &interval, &ds).unwrap();
match ret {
query::DataType::String(s) => assert_eq!(s, "test"),
query::DataType::String(s) => assert_eq!(s, "test \" with escaped quote"),
_ => panic!("Wrong datatype")
}
}
Expand Down

0 comments on commit fd09011

Please sign in to comment.