Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,11 @@ pub trait Dialect: Debug + Any {
fn supports_quote_delimited_string(&self) -> bool {
false
}

/// Returns true if the dialect considers the `&&` operator as a boolean AND operator.
fn supports_overlap_as_and_operator(&self) -> bool {
false
}
}

/// This represents the operators for which precedence must be defined
Expand Down
5 changes: 5 additions & 0 deletions src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ impl Dialect for MySqlDialect {
fn supports_cross_join_constraint(&self) -> bool {
true
}

/// See: <https://dev.mysql.com/doc/refman/8.4/en/expressions.html>
fn supports_overlap_as_and_operator(&self) -> bool {
true
}
}

/// `LOCK TABLES`
Expand Down
3 changes: 3 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,9 @@ impl<'a> Parser<'a> {
Token::Overlap if dialect_is!(dialect is PostgreSqlDialect | GenericDialect) => {
Some(BinaryOperator::PGOverlap)
}
Token::Overlap if dialect.supports_overlap_as_and_operator() => {
Some(BinaryOperator::And)
}
Token::CaretAt if dialect_is!(dialect is PostgreSqlDialect | GenericDialect) => {
Some(BinaryOperator::PGStartsWith)
}
Expand Down
6 changes: 6 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17972,3 +17972,9 @@ fn parse_select_parenthesized_wildcard() {
assert_eq!(select2.projection.len(), 1);
assert!(matches!(select2.projection[0], SelectItem::Wildcard(_)));
}

#[test]
fn parse_overlap_as_bool_and() {
let dialects = all_dialects_where(|d| d.supports_overlap_as_and_operator());
dialects.one_statement_parses_to("SELECT x && y", "SELECT x AND y");
}
Loading