Skip to content

Commit

Permalink
Add non-self-describing caveat for IpAddr, Uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
chmp committed Sep 30, 2024
1 parent 55cb727 commit b72beed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions serde_arrow/src/internal/schema/from_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ impl Tracer {

// check for known error messages of non self describing types
fn is_non_self_describing_error(s: &str) -> bool {
// chrono::*
s.contains("premature end of input")
// uuid::Uuid
|| s.contains("UUID parsing failed")
// std::net::IpAddr
|| s.contains("invalid IP address syntax")
}

struct TraceAny<'a>(&'a mut Tracer);
Expand Down
7 changes: 7 additions & 0 deletions serde_arrow/src/test/error_messages/trace_from_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ fn chrono_types_are_not_self_describing() {
assert_error_contains(&res, "non self describing type");
}

#[test]
fn net_ip_addr_is_not_self_describing() {
let res = SerdeArrowSchema::from_type::<Item<std::net::IpAddr>>(TracingOptions::default());
assert_error_contains(&res, "path: \"$.item\"");
assert_error_contains(&res, "non self describing type");
}

#[test]
fn unsupported_recursive_types() {
#[allow(unused)]
Expand Down
1 change: 1 addition & 0 deletions serde_arrow/src/test_with_arrow/impls/issue_203_uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ fn example_as_list() {
fn trace_from_type_does_not_work() {
let res = SerdeArrowSchema::from_type::<Item<Uuid>>(TracingOptions::default());
assert_error_contains(&res, "UUID parsing failed");
assert_error_contains(&res, "non self describing type");
}

0 comments on commit b72beed

Please sign in to comment.