zerodds-sql-filter

Layer 4. OMG DDS 1.4 §B.2.1 ContentFilteredTopic filter-expression parser + evaluator.

SQL-92 subset with %N parameters, full §B.2.1 coverage incl. BETWEEN/NOT BETWEEN and LIKE.

Source: crates/sql-filter →

Quickstart

Parse a filter expression once, then evaluate it against any row that implements RowAccess. %N placeholders are bound from the parameter slice:

use zerodds_sql_filter::{parse, Value, RowAccess};
use std::collections::HashMap;

struct MapRow(HashMap<String, Value>);
impl RowAccess for MapRow {
    fn get(&self, path: &str) -> Option<Value> {
        self.0.get(path).cloned()
    }
}

let expr = parse("color = %0 AND x > 10").unwrap();
let row = MapRow(HashMap::from([
    ("color".into(), Value::String("RED".into())),
    ("x".into(),     Value::Int(42)),
]));
let params = [Value::String("RED".into())];
assert_eq!(expr.evaluate(&row, &params), Ok(true));

Stability

1.0.0-rc.3.

zerodds-sql-filter

Layer 4. OMG DDS 1.4 §B.2.1 ContentFilteredTopic Filter-Expression Parser + Evaluator.

SQL-92-Subset mit %N-Parametern, voller §B.2.1-Coverage inkl. BETWEEN/NOT BETWEEN und LIKE.

Quelle: crates/sql-filter →

Quickstart

Filter-Expression einmal parsen, dann gegen jede Zeile auswerten, die RowAccess implementiert. %N-Platzhalter werden aus dem Parameter-Slice gebunden:

use zerodds_sql_filter::{parse, Value, RowAccess};
use std::collections::HashMap;

struct MapRow(HashMap<String, Value>);
impl RowAccess for MapRow {
    fn get(&self, path: &str) -> Option<Value> {
        self.0.get(path).cloned()
    }
}

let expr = parse("color = %0 AND x > 10").unwrap();
let row = MapRow(HashMap::from([
    ("color".into(), Value::String("RED".into())),
    ("x".into(),     Value::Int(42)),
]));
let params = [Value::String("RED".into())];
assert_eq!(expr.evaluate(&row, &params), Ok(true));

Stabilität

1.0.0-rc.3.