mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 07:24:10 +00:00
Support for postgres String Constants with Unicode Escapes (#1355)
This commit is contained in:
parent
c3ba2f33c6
commit
bc15f7b4ce
7 changed files with 180 additions and 0 deletions
|
@ -4441,3 +4441,35 @@ fn test_table_unnest_with_ordinality() {
|
|||
_ => panic!("Expecting TableFactor::UNNEST with ordinality"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escaped_string_literal() {
|
||||
match pg().verified_expr(r#"E'\n'"#) {
|
||||
Expr::Value(Value::EscapedStringLiteral(s)) => {
|
||||
assert_eq!("\n", s);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unicode_string_literal() {
|
||||
let pairs = [
|
||||
// Example from the postgres docs
|
||||
(r#"U&'\0441\043B\043E\043D'"#, "слон"),
|
||||
// High unicode code point (> 0xFFFF)
|
||||
(r#"U&'\+01F418'"#, "🐘"),
|
||||
// Escaped backslash
|
||||
(r#"U&'\\'"#, r#"\"#),
|
||||
// Escaped single quote
|
||||
(r#"U&''''"#, "'"),
|
||||
];
|
||||
for (input, expected) in pairs {
|
||||
match pg_and_generic().verified_expr(input) {
|
||||
Expr::Value(Value::UnicodeStringLiteral(s)) => {
|
||||
assert_eq!(expected, s);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue