Skip to content

Commit d4e5b4d

Browse files
mskrzypkowsMaciej Skrzypkowski
and
Maciej Skrzypkowski
authored
Support National string literal with lower case n (apache#612)
* National string literal with lower case n It's used by Snowflake * Corrected DB name Co-authored-by: Maciej Skrzypkowski <[email protected]>
1 parent 0724ef1 commit d4e5b4d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: src/tokenizer.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ impl<'a> Tokenizer<'a> {
387387
}
388388
Ok(Some(Token::Whitespace(Whitespace::Newline)))
389389
}
390-
'N' => {
390+
// Redshift uses lower case n for national string literal
391+
n @ 'N' | n @ 'n' => {
391392
chars.next(); // consume, to check the next char
392393
match chars.peek() {
393394
Some('\'') => {
@@ -397,7 +398,7 @@ impl<'a> Tokenizer<'a> {
397398
}
398399
_ => {
399400
// regular identifier starting with an "N"
400-
let s = self.tokenize_word('N', chars);
401+
let s = self.tokenize_word(n, chars);
401402
Ok(Some(Token::make_word(&s, None)))
402403
}
403404
}

Diff for: tests/sqlparser_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,7 @@ fn parse_literal_string() {
28512851
);
28522852

28532853
one_statement_parses_to("SELECT x'deadBEEF'", "SELECT X'deadBEEF'");
2854+
one_statement_parses_to("SELECT n'national string'", "SELECT N'national string'");
28542855
}
28552856

28562857
#[test]

0 commit comments

Comments
 (0)