Skip to main content

regex_match

Function regex_match 

Source
pub fn regex_match<'a, E>(
    expr: E,
    pattern: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, E::Aggregate, Arg<E::Nullable, E::Sources>>
where E: Expr<'a, PostgresValue<'a>>, E::SQLType: Textual,
Expand description

Tests whether text matches a regular expression, case-sensitively (~).

expr must be textual (text, varchar, char or an enum); pattern is bound as a text parameter. The result is NULL when expr is NULL.

ยงExamples

use drizzle_postgres::expr::regex_match;
use drizzle_core::{ToSQL, expr::raw_non_null};
use drizzle_postgres::values::PostgresValue;
use drizzle_types::postgres::types::Text;

let name = raw_non_null::<PostgresValue, Text>("name");
let cond = regex_match(name, "^[A-Z]");
assert_eq!(cond.to_sql().sql(), "name ~ $1");