drizzle_postgres/expr/ilike.rs
1//! `PostgreSQL` ILIKE operators.
2
3use crate::values::PostgresValue;
4use drizzle_core::{SQL, ToSQL};
5
6/// Case-insensitive LIKE pattern matching (PostgreSQL-specific)
7///
8/// # Example
9///
10/// ```rust
11/// # let _ = r####"
12/// use drizzle_postgres::expr::ilike;
13///
14/// let query = ilike(user.name, "%john%");
15/// // Generates: "name" ILIKE '%john%'
16/// # "####;
17/// ```
18pub fn ilike<'a, L, R>(left: L, pattern: R) -> SQL<'a, PostgresValue<'a>>
19where
20 L: ToSQL<'a, PostgresValue<'a>>,
21 R: Into<PostgresValue<'a>>,
22{
23 use drizzle_core::sql::SQLChunk;
24 left.to_sql()
25 .push(SQLChunk::Raw("ILIKE".into()))
26 .append(SQL::param(pattern.into()))
27}
28
29/// Case-insensitive NOT LIKE pattern matching (PostgreSQL-specific)
30///
31/// # Example
32///
33/// ```rust
34/// # let _ = r####"
35/// use drizzle_postgres::expr::not_ilike;
36///
37/// let query = not_ilike(user.name, "%admin%");
38/// // Generates: "name" NOT ILIKE '%admin%'
39/// # "####;
40/// ```
41pub fn not_ilike<'a, L, R>(left: L, pattern: R) -> SQL<'a, PostgresValue<'a>>
42where
43 L: ToSQL<'a, PostgresValue<'a>>,
44 R: Into<PostgresValue<'a>>,
45{
46 use drizzle_core::sql::{SQLChunk, Token};
47 left.to_sql()
48 .push(Token::NOT)
49 .push(SQLChunk::Raw("ILIKE".into()))
50 .append(SQL::param(pattern.into()))
51}