@@ -14061,39 +14061,32 @@ impl<'a> Parser<'a> {
1406114061 /// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/optimizer-hints.html#optimizer-hints-overview)
1406214062 /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Comments.html#GUID-D316D545-89E2-4D54-977F-FC97815CD62E)
1406314063 fn maybe_parse_optimizer_hint(&mut self) -> Result<Option<OptimizerHint>, ParserError> {
14064- let supports_multiline = dialect_of!(self is MySqlDialect | OracleDialect | GenericDialect);
14065- let supports_singleline = dialect_of!(self is OracleDialect | GenericDialect);
14066- if !supports_multiline && !supports_singleline {
14064+ let supports_hints = self.dialect.supports_comment_optimizer_hint();
14065+ if !supports_hints {
1406714066 return Ok(None);
1406814067 }
1406914068 loop {
1407014069 let t = self.peek_nth_token_no_skip_ref(0);
1407114070 match &t.token {
1407214071 Token::Whitespace(ws) => {
1407314072 match ws {
14074- Whitespace::SingleLineComment { comment, prefix } => {
14075- return Ok(if supports_singleline && comment.starts_with("+") {
14076- let text = comment.split_at(1).1.into();
14077- let prefix = prefix.clone();
14078- self.next_token_no_skip(); // Consume the comment token
14079- Some(OptimizerHint {
14080- text,
14081- style: OptimizerHintStyle::SingleLine { prefix },
14082- })
14083- } else {
14084- None
14085- });
14086- }
14087- Whitespace::MultiLineComment(comment) => {
14088- return Ok(if supports_multiline && comment.starts_with("+") {
14089- let text = comment.split_at(1).1.into();
14090- self.next_token_no_skip(); // Consume the comment token
14091- Some(OptimizerHint {
14092- text,
14093- style: OptimizerHintStyle::MultiLine,
14094- })
14095- } else {
14096- None
14073+ Whitespace::SingleLineComment { comment, .. }
14074+ | Whitespace::MultiLineComment(comment) => {
14075+ return Ok(match comment.strip_prefix("+") {
14076+ None => None,
14077+ Some(text) => {
14078+ let hint = OptimizerHint {
14079+ text: text.into(),
14080+ style: if let Whitespace::SingleLineComment { prefix, .. } = ws {
14081+ OptimizerHintStyle::SingleLine { prefix: prefix.clone() }
14082+ } else {
14083+ OptimizerHintStyle::MultiLine
14084+ }
14085+ };
14086+ // Consume the comment token
14087+ self.next_token_no_skip();
14088+ Some(hint)
14089+ }
1409714090 });
1409814091 }
1409914092 Whitespace::Space | Whitespace::Tab | Whitespace::Newline => {
0 commit comments