phonograph/phono-pestgros/src/fragment_tests.rs

26 lines
612 B
Rust
Raw Normal View History

2026-02-13 08:00:23 +00:00
use std::error::Error;
use sqlx::{Postgres, QueryBuilder};
use crate::Expr;
#[test]
fn sql_converts_to_query_builder() -> Result<(), Box<dyn Error>> {
let expr = Expr::try_from("3 + 5 < 10")?;
assert_eq!(
QueryBuilder::<'_, Postgres>::from(expr).sql(),
"(($1) + ($2)) < ($3)",
);
Ok(())
}
#[test]
fn cmp_array_modifier_round_trips() -> Result<(), Box<dyn Error>> {
let expr = Expr::try_from("1 = 2 and 3 < any(array[4])")?;
assert_eq!(
QueryBuilder::<'_, Postgres>::from(expr).sql(),
"(($1) = ($2)) and (($3) < any (array[($4)]))",
);
Ok(())
}