pub trait ArrayOperand<Rhs> { }Expand description
SQL type pairs that the array operators (@>, <@, &&) accept.
Self is the SQL type of the left operand and Rhs the SQL type of the
right operand. The pair is accepted when:
- both are arrays,
Array<T>andArray<U>, andTisCompatiblewithU(soint4[]works withint8[], but not withtext[]); - the left side is an array and the right side is a
Placeholderor untyped SQL (Any); - the left side is untyped SQL (
Any), which accepts any right side.
Anything else, such as a single value or a plain Vec, is rejected at
compile time. Wrap a Rust list in PgArray to bind it as one array.
§Type safety
ⓘ
use drizzle_core::expr::raw_non_null;
use drizzle_postgres::expr::array_contains;
use drizzle_postgres::values::PostgresValue;
use drizzle_types::{Array, postgres::types::Text};
let tags = raw_non_null::<PostgresValue, Array<Text>>("tags");
// A single value is not an array: wrap it as `PgArray(vec!["rust"])`.
let _ = array_contains(tags, "rust");ⓘ
use drizzle_core::expr::raw_non_null;
use drizzle_postgres::expr::{array_overlaps, PgArray};
use drizzle_postgres::values::PostgresValue;
use drizzle_types::{Array, postgres::types::Int4};
let ids = raw_non_null::<PostgresValue, Array<Int4>>("ids");
// `int4[]` cannot be compared with `text[]`.
let _ = array_overlaps(ids, PgArray(vec!["1"]));Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".