Skip to content

Commit ecedbb1

Browse files
joocerayman-sigma
authored andcommitted
Enable custom dialects to support MATCH() AGAINST() (apache#1719)
1 parent e08aace commit ecedbb1

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/dialect/generic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ impl Dialect for GenericDialect {
147147
fn supports_array_typedef_size(&self) -> bool {
148148
true
149149
}
150+
151+
fn supports_match_against(&self) -> bool {
152+
true
153+
}
150154
}

src/dialect/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,11 @@ pub trait Dialect: Debug + Any {
479479
false
480480
}
481481

482+
/// Does the dialect support the `MATCH() AGAINST()` syntax?
483+
fn supports_match_against(&self) -> bool {
484+
false
485+
}
486+
482487
/// Dialect-specific infix parser override
483488
///
484489
/// This method is called to parse the next infix expression.

src/dialect/mysql.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ impl Dialect for MySqlDialect {
129129
fn requires_single_line_comment_whitespace(&self) -> bool {
130130
true
131131
}
132+
133+
fn supports_match_against(&self) -> bool {
134+
true
135+
}
132136
}
133137

134138
/// `LOCK TABLES`

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ impl<'a> Parser<'a> {
11981198
})))
11991199
}
12001200
Keyword::NOT => Ok(Some(self.parse_not()?)),
1201-
Keyword::MATCH if dialect_of!(self is MySqlDialect | GenericDialect) => {
1201+
Keyword::MATCH if self.dialect.supports_match_against() => {
12021202
Ok(Some(self.parse_match_against()?))
12031203
}
12041204
Keyword::STRUCT if self.dialect.supports_struct_literal() => {

0 commit comments

Comments
 (0)