Merge pull request #95 from benesch/hex-literals

Support hexadecimal string literals
This commit is contained in:
Nikhil Benesch 2019-06-03 11:49:25 -04:00 committed by GitHub
commit b12fb34f3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 3 deletions

View file

@ -952,9 +952,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])
@ -963,6 +963,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]