#![cfg(feature = "postgres")]
fn call_site_a() -> &'static str {
zeph_db::sql!("SELECT id FROM messages WHERE conversation_id = ?")
}
fn call_site_b() -> &'static str {
zeph_db::sql!("SELECT id FROM messages WHERE conversation_id = ?")
}
#[test]
fn sql_macro_caches_per_call_site_not_globally() {
let a1 = call_site_a();
let a2 = call_site_a();
let b1 = call_site_b();
assert_eq!(a1, "SELECT id FROM messages WHERE conversation_id = $1");
assert_eq!(a1, b1, "rewritten content must match at both call sites");
assert!(
std::ptr::eq(a1.as_ptr(), a2.as_ptr()),
"same call site must reuse the cached allocation across repeated calls"
);
assert!(
!std::ptr::eq(a1.as_ptr(), b1.as_ptr()),
"distinct call sites must not share the same cached allocation"
);
}