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::{SqlDurationComparison, push_slots};
use crate::{
  DurationFilter,
  comparison::{At, Backend, ComplexComparison, ToDatabaseComparison, sql::Carrier},
};

/// See the Postgres row for what the crossing's item bound adds to a per-dialect map, and for why
/// SQLite's absence is not something it can fill.
impl<V> ToDatabaseComparison<V, sqlx::MySql> for DurationFilter
where
  V: Carrier<sqlx::MySql>,
{
  type Comparison = SqlDurationComparison<V, sqlx::MySql>;
}

/// A MySQL duration column is a `TIME`, and `V` is [`MySqlDuration`](crate::MySqlDuration) — the one
/// storage type with a carrier row here, so the checked conversion is the only one an undeclared
/// column can reach. Microseconds, a `±838:59:59` ceiling, and the SIGN carried across.
///
/// `core::time::Duration` has NO row on this dialect and could not have one honestly: sqlx-mysql
/// ships `Type<MySql> for Duration` and no `Encode`, so the type names a column it cannot bind to.
/// Its absence is now load-bearing twice over — it is also unsigned, where `TIME` is not.
///
/// That is the whole reason this kind gets one impl per dialect where its SQL is `col >= ?`
/// everywhere: what splits it is which `V` each dialect admits, and the two sets are disjoint.
impl<V> ComplexComparison<sqlx::MySql> for SqlDurationComparison<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);
    Ok(builder)
  }
}