| 747 | } |
| 748 | |
| 749 | Optional<IdInfo> extractEncodedIds(bson::BSONObj obj) { |
| 750 | bson::BSONElement el; |
| 751 | Optional<IdInfo> encodedIds; |
| 752 | bool elok = obj.getObjectID(el); |
| 753 | if (!elok) { |
| 754 | encodedIds = Optional<IdInfo>(); |
| 755 | } else { |
| 756 | Standalone<StringRef> encodedId; |
| 757 | Standalone<StringRef> valueEncodedId; |
| 758 | Optional<bson::BSONObj> idObj; |
| 759 | if (el.type() == bson::BSONType::Array) { |
| 760 | throw no_array_id(); |
| 761 | } else if (el.isABSONObj()) { |
| 762 | encodedId = DataValue(sortBsonObj(el.Obj())).encode_key_part(); |
| 763 | valueEncodedId = DataValue::subObject().encode_value(); |
| 764 | idObj = el.Obj().getOwned(); |
| 765 | } else { |
| 766 | encodedId = DataValue(el).encode_key_part(); |
| 767 | valueEncodedId = DataValue(el).encode_value(); |
| 768 | idObj = Optional<bson::BSONObj>(); |
| 769 | } |
| 770 | encodedIds = IdInfo(encodedId, valueEncodedId, idObj); |
| 771 | } |
| 772 | return encodedIds; |
| 773 | } |
| 774 | |
| 775 | Optional<IdInfo> extractEncodedIdsFromUpdate(bson::BSONObj update) { |
| 776 | for (auto i = update.begin(); i.more();) { |
no test coverage detected