Skip to content

Commit

Permalink
Fix incorrect output string from try_to_type (#3351)
Browse files Browse the repository at this point in the history
* Minor fix of try_to_type

* Add test
  • Loading branch information
viirya authored Dec 18, 2022
1 parent 491b023 commit a8c9685
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion arrow-ord/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ fn try_to_type_result<T>(
/// Type of expression is `Result<.., ArrowError>`
macro_rules! try_to_type {
($RIGHT: expr, $TY: ident) => {
try_to_type_result($RIGHT.$TY(), stringify!($RIGHT), stringify!($TYPE))
try_to_type_result($RIGHT.$TY(), &format!("{:?}", $RIGHT), stringify!($TY))
};
}

Expand Down Expand Up @@ -5827,4 +5827,22 @@ mod tests {
let r = gt_eq_dyn(&a, &b).unwrap();
assert_eq!(e, r);
}

#[derive(Debug)]
struct ToType {}

impl ToType {
fn to_i128(&self) -> Option<i128> {
None
}
}

#[test]
fn test_try_to_type() {
let a = ToType {};
let to_type = try_to_type!(a, to_i128).unwrap_err();
assert!(to_type
.to_string()
.contains("Could not convert ToType with to_i128"));
}
}

0 comments on commit a8c9685

Please sign in to comment.