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::SqlCountComparison;
use crate::{ScalarFilter, comparison::TryFromFilter};

/// The crossing every collection makes: `usize` operands into the `i64` a cardinality is compared as.
#[test]
fn a_cardinality_crosses_from_usize_into_the_familys_integer() {
  let crossed: SqlCountComparison<i64, ()> =
    SqlCountComparison::try_from_filter(ScalarFilter::<usize>::new().with_gt(3).with_in_([1, 2]))
      .unwrap();

  assert_eq!(crossed.gt(), Some(&3i64));
  assert_eq!(crossed.in_(), Some(&[1i64, 2][..]));
  assert_eq!(crossed.conjuncts(), 2);
}

/// An operand no `i64` can hold is REFUSED, where the sequence kind's ordinal saturates. The
/// difference is whose number it is: an ordinal is a slice index this crate produced, and this is a
/// client's operand.
#[test]
fn an_operand_past_the_integer_is_refused_rather_than_saturated() {
  let refused: Result<SqlCountComparison<i64, ()>, _> =
    SqlCountComparison::try_from_filter(ScalarFilter::<usize>::new().with_lt(usize::MAX));
  assert!(refused.is_err());
}

/// A cardinality is not quantified, so a comparison with no operator set asks nothing — which is what
/// makes a present-but-empty `count` fold into the collection's own emptiness rather than becoming a
/// predicate the way an empty element scope does.
#[test]
fn an_empty_cardinality_is_empty() {
  let empty: SqlCountComparison<i64, ()> =
    SqlCountComparison::try_from_filter(ScalarFilter::<usize>::new()).unwrap();
  assert!(empty.is_empty());
  assert_eq!(empty.conjuncts(), 0);
}