no-mistakes-postgres-engine 0.109.131

PostgreSQL embedded SQL extraction, schema catalog, and replay-safety analysis for no-mistakes
Documentation
use super::*;

#[test]
fn captured_transaction_sql_preserves_immutable_scalar_local() {
    let path = crate::test_support::fixture_root("postgres-transaction-callbacks")
        .join("captured-local-scalar.ts");
    let source = std::fs::read_to_string(&path).expect("fixture");
    let mut options = EmbeddedSqlOptions::configured("@example/db", &["query".into()])
        .with_scoped_executors(&["beginTransaction".into()], &[])
        .with_transaction_executor_types(&["TransactionQuery".into()])
        .with_trusted_sql_tags(&[crate::TrustedSqlTag {
            module: "@example/db".into(),
            name: "sql".into(),
        }]);
    options.track_transaction_helpers = true;
    let calls = extract_embedded_sql_from_source(&path, &source, &options).calls;
    let origins: Vec<Vec<_>> = calls
        .iter()
        .map(|call| {
            call.bound_value_origins
                .iter()
                .map(|(_, _, identity)| *identity)
                .collect()
        })
        .collect();
    assert_eq!(origins.len(), 2, "{calls:?}");
    assert_eq!(origins[0].len(), 1, "{calls:?}");
    assert_eq!(origins[0], origins[1], "{calls:?}");
}