use super::{SqlBytesComparison, push_slots};
use crate::comparison::{
At, Backend, ComplexComparison,
sql::{Carrier, not_wrapped, push_column},
};
impl<V> ComplexComparison<sqlx::Sqlite> for SqlBytesComparison<V, sqlx::Sqlite>
where
V: Carrier<sqlx::Sqlite>,
{
#[inline]
fn conjuncts(&self) -> usize {
Self::conjuncts(self)
}
fn apply<'q>(
&'q self,
at: At<'_>,
mut builder: <sqlx::Sqlite as Backend>::Builder<'q>,
) -> Result<<sqlx::Sqlite as Backend>::Builder<'q>, <sqlx::Sqlite as Backend>::Error> {
push_slots(self, at, &mut builder, push_bytes_contains);
Ok(builder)
}
}
fn push_bytes_contains<V>(
qb: &mut sqlx::QueryBuilder<sqlx::Sqlite>,
at: At<'_>,
operand: &V,
negated: bool,
) where
V: Carrier<sqlx::Sqlite>,
{
not_wrapped(qb, negated, |qb| {
qb.push("instr(");
push_column(qb, at);
qb.push(", ");
operand.push_bind(qb);
qb.push(") > 0");
});
}