diff --git a/test/boost/types_test.cc b/test/boost/types_test.cc index 05b3c85773..11f86e564f 100644 --- a/test/boost/types_test.cc +++ b/test/boost/types_test.cc @@ -56,6 +56,20 @@ BOOST_AUTO_TEST_CASE(test_null_is_not_empty) { BOOST_REQUIRE(empty != null); } +BOOST_AUTO_TEST_CASE(test_null_data_value_to_parsable_string) { + auto null_utf8 = data_value::make_null(utf8_type); + BOOST_REQUIRE_EQUAL(null_utf8.to_parsable_string(), "null"); + + auto null_int = data_value::make_null(int32_type); + BOOST_REQUIRE_EQUAL(null_int.to_parsable_string(), "null"); + + auto null_list = data_value::make_null(list_type_impl::get_instance(int32_type, true)); + BOOST_REQUIRE_EQUAL(null_list.to_parsable_string(), "null"); + + auto null_map = data_value::make_null(map_type_impl::get_instance(utf8_type, int32_type, true)); + BOOST_REQUIRE_EQUAL(null_map.to_parsable_string(), "null"); +} + BOOST_AUTO_TEST_CASE(test_bytes_type_string_conversions) { BOOST_REQUIRE(bytes_type->equal(bytes_type->from_string("616263646566"), bytes_type->decompose(data_value(bytes{"abcdef"})))); } diff --git a/types/types.cc b/types/types.cc index 5284d92a0e..cf319167a8 100644 --- a/types/types.cc +++ b/types/types.cc @@ -3602,6 +3602,10 @@ data_value::data_value(empty_type_representation e) : data_value(make_new(empty_ } sstring data_value::to_parsable_string() const { + if (is_null()) { + return "null"; + } + // For some reason trying to do it using fmt::format refuses to compile // auto to_parsable_str_transform = std::views::transform([](const data_value& dv) -> sstring { // return dv.to_parsable_string();