Support hexadecimal string literals

This commit is contained in:
Nikhil Benesch 2019-05-29 18:18:35 -04:00
parent 2308c1c6f7
commit eba3983268
No known key found for this signature in database
GPG key ID: F7386C5DEADABA7F
4 changed files with 36 additions and 3 deletions

View file

@ -923,9 +923,9 @@ fn parse_aggregate_with_group_by() {
#[test]
fn parse_literal_string() {
let sql = "SELECT 'one', N'national string'";
let sql = "SELECT 'one', N'national string', X'deadBEEF'";
let select = verified_only_select(sql);
assert_eq!(2, select.projection.len());
assert_eq!(3, select.projection.len());
assert_eq!(
&ASTNode::SQLValue(Value::SingleQuotedString("one".to_string())),
expr_from_projection(&select.projection[0])
@ -934,6 +934,12 @@ fn parse_literal_string() {
&ASTNode::SQLValue(Value::NationalStringLiteral("national string".to_string())),
expr_from_projection(&select.projection[1])
);
assert_eq!(
&ASTNode::SQLValue(Value::HexStringLiteral("deadBEEF".to_string())),
expr_from_projection(&select.projection[2])
);
one_statement_parses_to("SELECT x'deadBEEF'", "SELECT X'deadBEEF'");
}
#[test]