@@ -14020,39 +14020,32 @@ impl<'a> Parser<'a> {
1402014020 /// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/optimizer-hints.html#optimizer-hints-overview)
1402114021 /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Comments.html#GUID-D316D545-89E2-4D54-977F-FC97815CD62E)
1402214022 fn maybe_parse_optimizer_hint(&mut self) -> Result<Option<OptimizerHint>, ParserError> {
14023- let supports_multiline = dialect_of!(self is MySqlDialect | OracleDialect | GenericDialect);
14024- let supports_singleline = dialect_of!(self is OracleDialect | GenericDialect);
14025- if !supports_multiline && !supports_singleline {
14023+ let supports_hints = self.dialect.supports_comment_optimizer_hint();
14024+ if !supports_hints {
1402614025 return Ok(None);
1402714026 }
1402814027 loop {
1402914028 let t = self.peek_nth_token_no_skip_ref(0);
1403014029 match &t.token {
1403114030 Token::Whitespace(ws) => {
1403214031 match ws {
14033- Whitespace::SingleLineComment { comment, prefix } => {
14034- return Ok(if supports_singleline && comment.starts_with("+") {
14035- let text = comment.split_at(1).1.into();
14036- let prefix = prefix.clone();
14037- self.next_token_no_skip(); // Consume the comment token
14038- Some(OptimizerHint {
14039- text,
14040- style: OptimizerHintStyle::SingleLine { prefix },
14041- })
14042- } else {
14043- None
14044- });
14045- }
14046- Whitespace::MultiLineComment(comment) => {
14047- return Ok(if supports_multiline && comment.starts_with("+") {
14048- let text = comment.split_at(1).1.into();
14049- self.next_token_no_skip(); // Consume the comment token
14050- Some(OptimizerHint {
14051- text,
14052- style: OptimizerHintStyle::MultiLine,
14053- })
14054- } else {
14055- None
14032+ Whitespace::SingleLineComment { comment, .. }
14033+ | Whitespace::MultiLineComment(comment) => {
14034+ return Ok(match comment.strip_prefix("+") {
14035+ None => None,
14036+ Some(text) => {
14037+ let hint = OptimizerHint {
14038+ text: text.into(),
14039+ style: if let Whitespace::SingleLineComment { prefix, .. } = ws {
14040+ OptimizerHintStyle::SingleLine { prefix: prefix.clone() }
14041+ } else {
14042+ OptimizerHintStyle::MultiLine
14043+ }
14044+ };
14045+ // Consume the comment token
14046+ self.next_token_no_skip();
14047+ Some(hint)
14048+ }
1405614049 });
1405714050 }
1405814051 Whitespace::Space | Whitespace::Tab | Whitespace::Newline => {
0 commit comments