Summary
The #[pg_test] attribute parses its expected = "..." argument with a hand-rolled TokenTree walker instead of syn. This causes bug:
Raw-string corruption — expected values written as raw strings (needed whenever the expected Postgres error message contains a ") are silently mangled, so the test never matches the real error.
pre-prepare
/// Raises an error whose message contains a literal double-quote: foo "bar"
#[pg_extern]
fn raise_quoted_error() -> &'static str {
error!(r#"foo "bar""#);
}
Bug — raw-string corruption
#[pg_test(error = r#"foo "bar""#)]
fn bug1_raw_string_expected_is_corrupted() {
Spi::get_one::<&str>("SELECT raise_quoted_error()").unwrap();
}
Result:
Client Error:
foo "bar"
postgres location: lib.rs:8
rust location: <unknown>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
tests::pg_bug1_raw_string_expected_is_corrupted
The real error message from raise_quoted_error() is foo "bar", so the test fails with a mismatch even though the author wrote the correct expected string.
Environment
Summary
The #[pg_test] attribute parses its expected = "..." argument with a hand-rolled TokenTree walker instead of syn. This causes bug:
Raw-string corruption — expected values written as raw strings (needed whenever the expected Postgres error message contains a ") are silently mangled, so the test never matches the real error.
pre-prepare
Bug — raw-string corruption
Result:
The real error message from
raise_quoted_error()is foo "bar", so the test fails with a mismatch even though the author wrote the correct expected string.Environment