You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/12/18 22:57:00 UTC

[arrow-rs] branch master updated: Fix incorrect output string from try_to_type (#3351)

This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new a8c968584 Fix incorrect output string from try_to_type (#3351)
a8c968584 is described below

commit a8c968584e2d19587c48e8c9099c8d8f7ffffba3
Author: Liang-Chi Hsieh <vi...@gmail.com>
AuthorDate: Sun Dec 18 14:56:55 2022 -0800

    Fix incorrect output string from try_to_type (#3351)
    
    * Minor fix of try_to_type
    
    * Add test
---
 arrow-ord/src/comparison.rs | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/arrow-ord/src/comparison.rs b/arrow-ord/src/comparison.rs
index 196590008..80c8b6b1c 100644
--- a/arrow-ord/src/comparison.rs
+++ b/arrow-ord/src/comparison.rs
@@ -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))
     };
 }
 
@@ -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"));
+    }
 }