From 4a1fd280901d2dc4a4e98d765dec04c1667333f1 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Sat, 4 Jul 2026 11:07:10 +0000 Subject: [PATCH] Update value-mapping accepts tests for json/jsonb support Two unit tests still asserted that `json` is rejected by the value mapping, which became stale when json/jsonb decode and encode were added: `accepts_lists_match_supported_types` now checks json/jsonb are accepted by both `ToSql` and the Python decoder (while remaining outside the shared scalar list), and `from_sql_rejects_unsupported_column_type` uses `uuid` as its genuinely-unsupported type. Full `cargo test` is green again (157 passed); caught by a full-suite run after filtered runs had missed it. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01W3G4M92AmwSSZCbmtMJU3d --- rust/src/database/postgres/value.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rust/src/database/postgres/value.rs b/rust/src/database/postgres/value.rs index 178e2dbec6..04c76debf9 100644 --- a/rust/src/database/postgres/value.rs +++ b/rust/src/database/postgres/value.rs @@ -890,7 +890,18 @@ mod tests { ); } - for ty in [Type::JSON, Type::TIMESTAMPTZ, Type::UUID] { + // `json`/`jsonb`/`jsonpath` are additionally accepted by both the + // Python decoder and `ToSql` (see their `accepts` overrides), but not + // by the shared scalar list. + for ty in [Type::JSON, Type::JSONB] { + assert!(::accepts(&ty), "ToSql should accept {ty}"); + assert!( + ::accepts(&ty), + "FromSql should accept {ty}" + ); + } + + for ty in [Type::TIMESTAMPTZ, Type::UUID] { assert!( !::accepts(&ty), "ToSql should reject {ty}" @@ -956,7 +967,7 @@ mod tests { // out of sync; decoding an unsupported type is an error, not a panic. Python::initialize(); Python::attach(|_py| { - assert!(PythonPgFromSql::from_sql(&Type::JSON, b"{}").is_err()); + assert!(PythonPgFromSql::from_sql(&Type::UUID, b"0123456789abcdef").is_err()); }); }