mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-26 15:39:12 +00:00
Support National string literal with lower case n
(#612)
* National string literal with lower case n It's used by Snowflake * Corrected DB name Co-authored-by: Maciej Skrzypkowski <maciej.skrzypkowski@satoricyber.com>
This commit is contained in:
parent
0724ef13a4
commit
d4e5b4d5e8
2 changed files with 4 additions and 2 deletions
|
@ -387,7 +387,8 @@ impl<'a> Tokenizer<'a> {
|
||||||
}
|
}
|
||||||
Ok(Some(Token::Whitespace(Whitespace::Newline)))
|
Ok(Some(Token::Whitespace(Whitespace::Newline)))
|
||||||
}
|
}
|
||||||
'N' => {
|
// Redshift uses lower case n for national string literal
|
||||||
|
n @ 'N' | n @ 'n' => {
|
||||||
chars.next(); // consume, to check the next char
|
chars.next(); // consume, to check the next char
|
||||||
match chars.peek() {
|
match chars.peek() {
|
||||||
Some('\'') => {
|
Some('\'') => {
|
||||||
|
@ -397,7 +398,7 @@ impl<'a> Tokenizer<'a> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// regular identifier starting with an "N"
|
// regular identifier starting with an "N"
|
||||||
let s = self.tokenize_word('N', chars);
|
let s = self.tokenize_word(n, chars);
|
||||||
Ok(Some(Token::make_word(&s, None)))
|
Ok(Some(Token::make_word(&s, None)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2851,6 +2851,7 @@ fn parse_literal_string() {
|
||||||
);
|
);
|
||||||
|
|
||||||
one_statement_parses_to("SELECT x'deadBEEF'", "SELECT X'deadBEEF'");
|
one_statement_parses_to("SELECT x'deadBEEF'", "SELECT X'deadBEEF'");
|
||||||
|
one_statement_parses_to("SELECT n'national string'", "SELECT N'national string'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue