Skip to content

Commit f685cb1

Browse files
authored
Merge branch 'main' into support_colon_eq_operator_mysql
2 parents c7a3ba5 + 53aba68 commit f685cb1

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ pub enum Expr {
10271027
/// [(1)]: https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html#function_match
10281028
MatchAgainst {
10291029
/// `(<col>, <col>, ...)`.
1030-
columns: Vec<Ident>,
1030+
columns: Vec<ObjectName>,
10311031
/// `<expr>`.
10321032
match_value: Value,
10331033
/// `<search modifier>`

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,7 @@ impl<'a> Parser<'a> {
27042704
/// This method will raise an error if the column list is empty or with invalid identifiers,
27052705
/// the match expression is not a literal string, or if the search modifier is not valid.
27062706
pub fn parse_match_against(&mut self) -> Result<Expr, ParserError> {
2707-
let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
2707+
let columns = self.parse_parenthesized_qualified_column_list(Mandatory, false)?;
27082708

27092709
self.expect_keyword_is(Keyword::AGAINST)?;
27102710

tests/sqlparser_mysql.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,6 +3455,34 @@ fn parse_cast_integers() {
34553455
.expect_err("CAST doesn't allow display width");
34563456
}
34573457

3458+
fn parse_match_against_with_alias() {
3459+
let sql = "SELECT tbl.ProjectID FROM surveys.tbl1 AS tbl WHERE MATCH (tbl.ReferenceID) AGAINST ('AAA' IN BOOLEAN MODE)";
3460+
match mysql().verified_stmt(sql) {
3461+
Statement::Query(query) => match *query.body {
3462+
SetExpr::Select(select) => match select.selection {
3463+
Some(Expr::MatchAgainst {
3464+
columns,
3465+
match_value,
3466+
opt_search_modifier,
3467+
}) => {
3468+
assert_eq!(
3469+
columns,
3470+
vec![ObjectName::from(vec![
3471+
Ident::new("tbl"),
3472+
Ident::new("ReferenceID")
3473+
])]
3474+
);
3475+
assert_eq!(match_value, Value::SingleQuotedString("AAA".to_owned()));
3476+
assert_eq!(opt_search_modifier, Some(SearchModifier::InBooleanMode));
3477+
}
3478+
_ => unreachable!(),
3479+
},
3480+
_ => unreachable!(),
3481+
},
3482+
_ => unreachable!(),
3483+
}
3484+
}
3485+
34583486
#[test]
34593487
fn test_variable_assignment_using_colon_equal() {
34603488
let sql_select = "SELECT @price := price, @tax := price * 0.1 FROM products WHERE id = 1";

0 commit comments

Comments
 (0)