| 2803 | |
| 2804 | #[test] |
| 2805 | fn test_cast_value_to_binary_expr() { |
| 2806 | let tests = [ |
| 2807 | ( |
| 2808 | Expr::Cast(Cast::new( |
| 2809 | Box::new(Expr::Literal( |
| 2810 | ScalarValue::Utf8(Some("blah".to_string())), |
| 2811 | None, |
| 2812 | )), |
| 2813 | DataType::Binary, |
| 2814 | )), |
| 2815 | "'blah'", |
| 2816 | ), |
| 2817 | ( |
| 2818 | Expr::Cast(Cast::new( |
| 2819 | Box::new(Expr::Literal( |
| 2820 | ScalarValue::Utf8(Some("blah".to_string())), |
| 2821 | None, |
| 2822 | )), |
| 2823 | DataType::BinaryView, |
| 2824 | )), |
| 2825 | "'blah'", |
| 2826 | ), |
| 2827 | ]; |
| 2828 | for (value, expected) in tests { |
| 2829 | let dialect = CustomDialectBuilder::new().build(); |
| 2830 | let unparser = Unparser::new(&dialect); |
| 2831 | |
| 2832 | let ast = unparser.expr_to_sql(&value).expect("to be unparsed"); |
| 2833 | let actual = format!("{ast}"); |
| 2834 | |
| 2835 | assert_eq!(actual, expected); |
| 2836 | } |
| 2837 | } |
| 2838 | |
| 2839 | #[test] |
| 2840 | fn custom_dialect_use_char_for_utf8_cast() -> Result<()> { |