Fix map at operator returning null from a map (#1039)

Fix map returning null from a map and not throwing exception if key is not present
This commit is contained in:
Josipmrden 2023-06-27 15:04:12 +02:00 committed by GitHub
parent cb843ee664
commit 5ce1526995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2218,7 +2218,14 @@ inline bool Map::Empty() const { return Size() == 0; }
inline const Value Map::operator[](std::string_view key) const { return Value(mgp::map_at(ptr_, key.data())); }
inline const Value Map::At(std::string_view key) const { return Value(mgp::map_at(ptr_, key.data())); }
inline const Value Map::At(std::string_view key) const {
auto *ptr = mgp::map_at(ptr_, key.data());
if (ptr) {
return Value(ptr);
}
return Value();
}
inline Map::Iterator::Iterator(mgp_map_items_iterator *map_items_iterator) : map_items_iterator_(map_items_iterator) {
if (map_items_iterator_ == nullptr) return;