Parse true and false as identifiers in mssql (#1510)

This commit is contained in:
Ophir LOJKINE 2024-11-13 11:25:26 +01:00 committed by GitHub
parent 90824486df
commit 3a8369aaf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 97 additions and 60 deletions

View file

@ -1014,7 +1014,11 @@ impl<'a> Parser<'a> {
let next_token = self.next_token();
let expr = match next_token.token {
Token::Word(w) => match w.keyword {
Keyword::TRUE | Keyword::FALSE | Keyword::NULL => {
Keyword::TRUE | Keyword::FALSE if self.dialect.supports_boolean_literals() => {
self.prev_token();
Ok(Expr::Value(self.parse_value()?))
}
Keyword::NULL => {
self.prev_token();
Ok(Expr::Value(self.parse_value()?))
}
@ -7577,8 +7581,12 @@ impl<'a> Parser<'a> {
let location = next_token.location;
match next_token.token {
Token::Word(w) => match w.keyword {
Keyword::TRUE => Ok(Value::Boolean(true)),
Keyword::FALSE => Ok(Value::Boolean(false)),
Keyword::TRUE if self.dialect.supports_boolean_literals() => {
Ok(Value::Boolean(true))
}
Keyword::FALSE if self.dialect.supports_boolean_literals() => {
Ok(Value::Boolean(false))
}
Keyword::NULL => Ok(Value::Null),
Keyword::NoKeyword if w.quote_style.is_some() => match w.quote_style {
Some('"') => Ok(Value::DoubleQuotedString(w.value)),