Skip to content

Commit c36fcf8

Browse files
jnlt3ayman-sigma
authored andcommitted
PostgreSQL Tokenization: Fix unexpected characters after question mark being silently ignored (apache#2129)
1 parent 6a998ee commit c36fcf8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/tokenizer.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ impl<'a> Tokenizer<'a> {
17951795
}
17961796
}
17971797
Some('#') => self.consume_and_return(chars, Token::QuestionMarkSharp),
1798-
_ => self.consume_and_return(chars, Token::Question),
1798+
_ => Ok(Some(Token::Question)),
17991799
}
18001800
}
18011801
'?' => {
@@ -4240,4 +4240,23 @@ mod tests {
42404240
],
42414241
);
42424242
}
4243+
4244+
#[test]
4245+
fn tokenize_question_mark() {
4246+
let dialect = PostgreSqlDialect {};
4247+
let sql = "SELECT x ? y";
4248+
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
4249+
compare(
4250+
tokens,
4251+
vec![
4252+
Token::make_keyword("SELECT"),
4253+
Token::Whitespace(Whitespace::Space),
4254+
Token::make_word("x", None),
4255+
Token::Whitespace(Whitespace::Space),
4256+
Token::Question,
4257+
Token::Whitespace(Whitespace::Space),
4258+
Token::make_word("y", None),
4259+
],
4260+
)
4261+
}
42434262
}

0 commit comments

Comments
 (0)