ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
use super::{SqlBytesComparison, push_slots};
use crate::comparison::{
  At, Backend, ComplexComparison,
  sql::{Carrier, not_wrapped, push_column},
};

/// One impl per dialect, because what differs is the LEAF below rather than the walk above:
/// `push_slots` is this kind's one slot walk and every dialect calls it, so the impls cannot come to
/// disagree about which operators render or in what order.
impl<V> ComplexComparison<sqlx::Postgres> for SqlBytesComparison<V, sqlx::Postgres>
where
  V: Carrier<sqlx::Postgres>,
{
  #[inline]
  fn conjuncts(&self) -> usize {
    Self::conjuncts(self)
  }

  fn apply<'q>(
    &'q self,
    at: At<'_>,
    mut builder: <sqlx::Postgres as Backend>::Builder<'q>,
  ) -> Result<<sqlx::Postgres as Backend>::Builder<'q>, <sqlx::Postgres as Backend>::Error> {
    push_slots(self, at, &mut builder, push_bytes_contains);
    Ok(builder)
  }
}

fn push_bytes_contains<V>(
  qb: &mut sqlx::QueryBuilder<sqlx::Postgres>,
  at: At<'_>,
  operand: &V,
  negated: bool,
) where
  V: Carrier<sqlx::Postgres>,
{
  not_wrapped(qb, negated, |qb| {
    qb.push("position(");
    operand.push_bind(qb);
    qb.push(" in ");
    push_column(qb, at);
    qb.push(") > 0");
  });
}