| 674 | } |
| 675 | |
| 676 | fn jsonb_get_string<'b>( |
| 677 | left: ResultSpec<'b>, |
| 678 | right: ResultSpec<'b>, |
| 679 | stringify: bool, |
| 680 | ) -> ResultSpec<'b> { |
| 681 | eagerly(left, right, |left, right| { |
| 682 | let nested_spec = match (left, right) { |
| 683 | (Values::Nested(mut map_spec), Values::Within(key, key2)) if key == key2 => { |
| 684 | map_spec.remove(&key) |
| 685 | } |
| 686 | _ => None, |
| 687 | }; |
| 688 | |
| 689 | if let Some(field_spec) = nested_spec { |
| 690 | if stringify { |
| 691 | // We only preserve value-range information when stringification |
| 692 | // is a noop. (Common in real queries.) |
| 693 | let values = match field_spec.values { |
| 694 | Values::Empty => Values::Empty, |
| 695 | Values::Within(min @ Datum::String(_), max @ Datum::String(_)) => { |
| 696 | Values::Within(min, max) |
| 697 | } |
| 698 | Values::Within(_, _) | Values::Nested(_) | Values::All => Values::All, |
| 699 | }; |
| 700 | ResultSpec { |
| 701 | values, |
| 702 | ..field_spec |
| 703 | } |
| 704 | } else { |
| 705 | field_spec |
| 706 | } |
| 707 | } else { |
| 708 | // The implementation of `jsonb_get_string` always returns |
| 709 | // `Ok(...)`. Morally, everything has a string |
| 710 | // representation, and the worst you can get is a NULL, |
| 711 | // which maps to a NULL. |
| 712 | ResultSpec::any_infallible() |
| 713 | } |
| 714 | }) |
| 715 | } |
| 716 | |
| 717 | fn eq<'b>(left: ResultSpec<'b>, right: ResultSpec<'b>) -> ResultSpec<'b> { |
| 718 | eagerly(left, right, |left, right| { |