Skip to content

Enable custom dialects to support MATCH() AGAINST() #1719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/dialect/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ impl Dialect for GenericDialect {
fn supports_array_typedef_size(&self) -> bool {
true
}

fn supports_match_against(&self) -> bool {
true
}
}
5 changes: 5 additions & 0 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ pub trait Dialect: Debug + Any {
false
}

/// Does the dialect support the `MATCH() AGAINST()` syntax?
fn supports_match_against(&self) -> bool {
false
}

/// Dialect-specific infix parser override
///
/// This method is called to parse the next infix expression.
Expand Down
4 changes: 4 additions & 0 deletions src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ impl Dialect for MySqlDialect {
fn requires_single_line_comment_whitespace(&self) -> bool {
true
}

fn supports_match_against(&self) -> bool {
true
}
}

/// `LOCK TABLES`
Expand Down
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ impl<'a> Parser<'a> {
})))
}
Keyword::NOT => Ok(Some(self.parse_not()?)),
Keyword::MATCH if dialect_of!(self is MySqlDialect | GenericDialect) => {
Keyword::MATCH if self.dialect.supports_match_against() => {
Ok(Some(self.parse_match_against()?))
}
Keyword::STRUCT if self.dialect.supports_struct_literal() => {
Expand Down