pub fn cast<'a, V, E, Target>(
expr: E,
target_type: &'a str,
) -> SQLExpr<'a, V, Target, E::Nullable, E::Aggregate>Expand description
Cast an expression to a different type.
The target type marker specifies the result type for the type system, while the SQL type string specifies the actual SQL type name (dialect-specific). Preserves the input expression’s nullability and aggregate marker.
§Example
ⓘ
use drizzle_core::expr::cast;
use drizzle_core::types::Text;
// SELECT CAST(users.age AS TEXT)
let age_text = cast::<_, _, _, Text>(users.age, "TEXT");
// PostgreSQL-specific
let age_text = cast::<_, _, _, Text>(users.age, "VARCHAR(255)");