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