Allow string values in pragma commands (#1101)

Co-authored-by: Michael Ionov <michael@appdome.com>
This commit is contained in:
Michael Ionov 2024-01-18 22:22:35 +02:00 committed by GitHub
parent 3ec337ec5f
commit b0b62887a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 63 additions and 2 deletions

View file

@ -8470,11 +8470,24 @@ impl<'a> Parser<'a> {
})
}
fn parse_pragma_value(&mut self) -> Result<Value, ParserError> {
match self.parse_value()? {
v @ Value::SingleQuotedString(_) => Ok(v),
v @ Value::DoubleQuotedString(_) => Ok(v),
v @ Value::Number(_, _) => Ok(v),
v @ Value::Placeholder(_) => Ok(v),
_ => {
self.prev_token();
self.expected("number or string or ? placeholder", self.peek_token())
}
}
}
// PRAGMA [schema-name '.'] pragma-name [('=' pragma-value) | '(' pragma-value ')']
pub fn parse_pragma(&mut self) -> Result<Statement, ParserError> {
let name = self.parse_object_name()?;
if self.consume_token(&Token::LParen) {
let value = self.parse_number_value()?;
let value = self.parse_pragma_value()?;
self.expect_token(&Token::RParen)?;
Ok(Statement::Pragma {
name,
@ -8484,7 +8497,7 @@ impl<'a> Parser<'a> {
} else if self.consume_token(&Token::Eq) {
Ok(Statement::Pragma {
name,
value: Some(self.parse_number_value()?),
value: Some(self.parse_pragma_value()?),
is_eq: true,
})
} else {