Skip to content

Commit

Permalink
Make OxQL UUID parsing case-insensitive
Browse files Browse the repository at this point in the history
Fixes #6358
  • Loading branch information
bnaecker committed Aug 16, 2024
1 parent d7d4bea commit 8b79eb9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions oximeter/db/src/oxql/ast/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ peg::parser! {
rule dashed_uuid_literal() -> Uuid
= s:$(
"\""
['a'..='f' | '0'..='9']*<8> "-"
['a'..='f' | '0'..='9']*<4> "-"
['a'..='f' | '0'..='9']*<4> "-"
['a'..='f' | '0'..='9']*<4> "-"
['a'..='f' | '0'..='9']*<12>
['a'..='f' | 'A'..='F' | '0'..='9']*<8> "-"
['a'..='f' | 'A'..='F' | '0'..='9']*<4> "-"
['a'..='f' | 'A'..='F' | '0'..='9']*<4> "-"
['a'..='f' | 'A'..='F' | '0'..='9']*<4> "-"
['a'..='f' | 'A'..='F' | '0'..='9']*<12>
"\""
) {?
let Some(middle) = s.get(1..37) else {
Expand All @@ -202,7 +202,7 @@ peg::parser! {
middle.parse().or(Err("invalid UUID literal"))
}
rule undashed_uuid_literal() -> Uuid
= s:$("\"" ['a'..='f' | '0'..='9']*<32> "\"") {?
= s:$("\"" ['a'..='f' | 'A'..='F' | '0'..='9']*<32> "\"") {?
let Some(middle) = s.get(1..33) else {
return Err("invalid UUID literal");
};
Expand Down Expand Up @@ -734,6 +734,15 @@ mod tests {
.is_err());
}

#[test]
fn test_uuid_literal_is_case_insensitive() {
const ID: Uuid = uuid::uuid!("880D82A1-102F-4699-BE1A-7E2A6A469E8E");
let as_str = format!("\"{ID}\"");
let as_lower = as_str.to_lowercase();
assert_eq!(query_parser::uuid_literal_impl(&as_str).unwrap(), ID,);
assert_eq!(query_parser::uuid_literal_impl(&as_lower).unwrap(), ID,);
}

#[test]
fn test_integer_literal() {
assert_eq!(query_parser::integer_literal_impl("1").unwrap(), 1);
Expand Down

0 comments on commit 8b79eb9

Please sign in to comment.