()
| 4351 | /// Ord/PartialOrd for DatumMap: less, equal, greater (by key then value). |
| 4352 | #[mz_ore::test] |
| 4353 | fn test_datum_map_ordering() { |
| 4354 | let mut row_a1 = Row::default(); |
| 4355 | row_a1.packer().push_dict_with(|p| { |
| 4356 | p.push(Datum::String("a")); |
| 4357 | p.push(Datum::Int32(1)); |
| 4358 | }); |
| 4359 | let map_a1 = row_a1.unpack_first().unwrap_map(); |
| 4360 | |
| 4361 | let mut row_a2 = Row::default(); |
| 4362 | row_a2.packer().push_dict_with(|p| { |
| 4363 | p.push(Datum::String("a")); |
| 4364 | p.push(Datum::Int32(2)); |
| 4365 | }); |
| 4366 | let map_a2 = row_a2.unpack_first().unwrap_map(); |
| 4367 | |
| 4368 | let mut row_b1 = Row::default(); |
| 4369 | row_b1.packer().push_dict_with(|p| { |
| 4370 | p.push(Datum::String("b")); |
| 4371 | p.push(Datum::Int32(1)); |
| 4372 | }); |
| 4373 | let map_b1 = row_b1.unpack_first().unwrap_map(); |
| 4374 | |
| 4375 | assert_eq!(map_a1.cmp(&map_a2), Ordering::Less); |
| 4376 | assert_eq!(map_a2.cmp(&map_a1), Ordering::Greater); |
| 4377 | assert_eq!(map_a1.cmp(&map_a1), Ordering::Equal); |
| 4378 | assert_eq!(map_a1.cmp(&map_b1), Ordering::Less); // "a" < "b" |
| 4379 | } |
| 4380 | |
| 4381 | /// Datum puts Null last in the enum so that nulls sort last (PostgreSQL default). |
| 4382 | /// This ordering is used when comparing DatumList/DatumMap (e.g. jsonb_agg tiebreaker). |
nothing calls this directly
no test coverage detected