Repository: SeaQL/sea-query (Rust)

Issue:
Add overlap operator for Postgres
## Motivation
Add overlap operator for PostgreSQL in PgBinOper

```
anyrange && anyrange → boolean

Do the ranges overlap, that is, have any elements in common?

int8range(3,7) && int8range(4,12) → t
```

https://www.postgresql.org/docs/current/functions-range.html

## Proposed Solutions


```rust
PgExpr::overlap(expr);
```

And

```rust
Expr::expr(...).binary(PgBinOper::Overlap, ...);
````




Discussion:
I would like to take this issue. May I create a pull request?



Patch:
diff --git a/src/backend/postgres/query.rs b/src/backend/postgres/query.rs
index ddb0710c0..0dc9ff35d 100644
--- a/src/backend/postgres/query.rs
+++ b/src/backend/postgres/query.rs
@@ -47,6 +47,7 @@ impl QueryBuilder for PostgresQueryBuilder {
                     PgBinOper::Contains => "@>",
                     PgBinOper::Contained => "<@",
                     PgBinOper::Concatenate => "||",
+                    PgBinOper::Overlap => "&&",
                     PgBinOper::Similarity => "%",
                     PgBinOper::WordSimilarity => "<%",
                     PgBinOper::StrictWordSimilarity => "<<%",
diff --git a/src/extension/postgres/mod.rs b/src/extension/postgres/mod.rs
index 908f895cb..abe5424a8 100644
--- a/src/extension/postgres/mod.rs
+++ b/src/extension/postgres/mod.rs
@@ -21,6 +21,7 @@ pub enum PgBinOper {
     Contains,
     Contained,
     Concatenate,
+    Overlap,
     Similarity,
     WordSimilarity,
     StrictWordSimilarity,


Test patch:
diff --git a/tests/postgres/query.rs b/tests/postgres/query.rs
index 587759747..a99311142 100644
--- a/tests/postgres/query.rs
+++ b/tests/postgres/query.rs
@@ -1801,6 +1801,51 @@ fn sub_query_with_fn() {
     );
 }
 
+#[test]
+fn select_array_contains_bin_oper() {
+    assert_eq!(
+        Query::select()
+            .column(Char::Character)
+            .from(Char::Table)
+            .and_where(Expr::col(Char::Character).binary(PgBinOper::Contains, Expr::val("test")))
+            .build(PostgresQueryBuilder),
+        (
+            r#"SELECT "character" FROM "character" WHERE "character" @> $1"#.to_owned(),
+            Values(vec!["test".into()])
+        )
+    );
+}
+
+#[test]
+fn select_array_contained_bin_oper() {
+    assert_eq!(
+        Query::select()
+            .column(Char::Character)
+            .from(Char::Table)
+            .and_where(Expr::col(Char::Character).binary(PgBinOper::Contained, Expr::val("test")))
+            .build(PostgresQueryBuilder),
+        (
+            r#"SELECT "character" FROM "character" WHERE "character" <@ $1"#.to_owned(),
+            Values(vec!["test".into()])
+        )
+    );
+}
+
+#[test]
+fn select_array_overlap_bin_oper() {
+    assert_eq!(
+        Query::select()
+            .column(Char::Character)
+            .from(Char::Table)
+            .and_where(Expr::col(Char::Character).binary(PgBinOper::Overlap, Expr::val("test")))
+            .build(PostgresQueryBuilder),
+        (
+            r#"SELECT "character" FROM "character" WHERE "character" && $1"#.to_owned(),
+            Values(vec!["test".into()])
+        )
+    );
+}
+
 #[test]
 fn get_json_field_bin_oper() {
     assert_eq!(