mod common;
use common::connect_test_client;
use futures::StreamExt;
#[tokio::test]
async fn test_hybrid_filtering() {
let client = connect_test_client().await.expect("connect");
let mut stream = client
.query::<serde_json::Value>("test.v_user")
.where_sql("1 = 1") .where_rust(|json| {
json["settings"]["notifications"].as_bool().unwrap_or(false)
})
.execute()
.await
.expect("query");
let mut filtered_users = Vec::new();
while let Some(item) = stream.next().await {
let json = item.expect("item");
filtered_users.push(json);
}
assert!(
!filtered_users.is_empty(),
"should have results from hybrid filtering"
);
for user in &filtered_users {
assert_eq!(
user["settings"]["notifications"].as_bool(),
Some(true),
"all filtered users should have notifications enabled"
);
}
println!(
"Filtered {} users with notifications enabled",
filtered_users.len()
);
}