diff --git a/src/query/common.cpp b/src/query/common.cpp index dc175bf43..cea9d760a 100644 --- a/src/query/common.cpp +++ b/src/query/common.cpp @@ -245,7 +245,7 @@ bool TypedValueCompare(const TypedValue &a, const TypedValue &b) { else return a.Value() < b.Value(); case TypedValue::Type::String: - return a.Value() < b.Value(); + return a.ValueString() < b.ValueString(); case TypedValue::Type::List: case TypedValue::Type::Map: case TypedValue::Type::Vertex: diff --git a/src/query/distributed/serialization.cpp b/src/query/distributed/serialization.cpp index 86766325c..0e6e1d108 100644 --- a/src/query/distributed/serialization.cpp +++ b/src/query/distributed/serialization.cpp @@ -25,7 +25,7 @@ void Save(const query::TypedValue &value, slk::Builder *builder, return; case query::TypedValue::Type::String: slk::Save(static_cast(4), builder); - slk::Save(value.Value(), builder); + slk::Save(value.ValueString(), builder); return; case query::TypedValue::Type::List: { slk::Save(static_cast(5), builder); diff --git a/src/query/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp index dede0b9b5..eb747eb91 100644 --- a/src/query/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -122,7 +122,7 @@ TypedValue Size(TypedValue *args, int64_t nargs, const EvaluationContext &, return static_cast( args[0].ValueList().size()); case TypedValue::Type::String: - return static_cast(args[0].Value().size()); + return static_cast(args[0].ValueString().size()); case TypedValue::Type::Map: // neo4j doesn't implement size for map, but I don't see a good reason not // to do it. @@ -217,7 +217,7 @@ TypedValue ToBoolean(TypedValue *args, int64_t nargs, const EvaluationContext &, case TypedValue::Type::Int: return args[0].ValueInt() != 0L; case TypedValue::Type::String: { - auto s = utils::ToUpperCase(utils::Trim(args[0].Value())); + auto s = utils::ToUpperCase(utils::Trim(args[0].ValueString())); if (s == "TRUE") return true; if (s == "FALSE") return false; // I think this is just stupid and that exception should be thrown, but @@ -244,7 +244,7 @@ TypedValue ToFloat(TypedValue *args, int64_t nargs, const EvaluationContext &, return args[0]; case TypedValue::Type::String: try { - return utils::ParseDouble(utils::Trim(args[0].Value())); + return utils::ParseDouble(utils::Trim(args[0].ValueString())); } catch (const utils::BasicException &) { return TypedValue::Null; } @@ -273,7 +273,7 @@ TypedValue ToInteger(TypedValue *args, int64_t nargs, const EvaluationContext &, // Yup, this is correct. String is valid if it has floating point // number, then it is parsed and converted to int. return static_cast( - utils::ParseDouble(utils::Trim(args[0].Value()))); + utils::ParseDouble(utils::Trim(args[0].ValueString()))); } catch (const utils::BasicException &) { return TypedValue::Null; } @@ -603,8 +603,8 @@ TypedValue StringMatchOperator(TypedValue *args, int64_t nargs, check_arg(args[0]); check_arg(args[1]); if (has_null) return TypedValue::Null; - const auto &s1 = args[0].Value(); - const auto &s2 = args[1].Value(); + const auto &s1 = args[0].ValueString(); + const auto &s2 = args[1].ValueString(); return Predicate(s1, s2); } diff --git a/src/query/interpret/eval.hpp b/src/query/interpret/eval.hpp index 985dd0624..dfa617002 100644 --- a/src/query/interpret/eval.hpp +++ b/src/query/interpret/eval.hpp @@ -184,7 +184,7 @@ class ExpressionEvaluator : public ExpressionVisitor { throw QueryRuntimeException("Expected a string as a map index, got {}.", index.type()); const auto &map = lhs.Value>(); - auto found = map.find(index.Value()); + auto found = map.find(index.ValueString()); if (found == map.end()) return TypedValue::Null; return found->second; } @@ -194,7 +194,7 @@ class ExpressionEvaluator : public ExpressionVisitor { throw QueryRuntimeException( "Expected a string as a property name, got {}.", index.type()); return lhs.Value().PropsAt( - dba_->Property(index.Value())); + dba_->Property(index.ValueString())); } if (lhs.IsEdge()) { @@ -202,7 +202,7 @@ class ExpressionEvaluator : public ExpressionVisitor { throw QueryRuntimeException( "Expected a string as a property name, got {}.", index.type()); return lhs.Value().PropsAt( - dba_->Property(index.Value())); + dba_->Property(index.ValueString())); } // lhs is Null diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 44cbbdd81..9170e606a 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -2612,7 +2612,7 @@ class AggregateCursor : public Cursor { if (key.type() != TypedValue::Type::String) throw QueryRuntimeException("Map key must be a string."); value_it->Value>().emplace( - key.Value(), input_value); + key.ValueString(), input_value); break; } continue; @@ -2664,7 +2664,7 @@ class AggregateCursor : public Cursor { if (key.type() != TypedValue::Type::String) throw QueryRuntimeException("Map key must be a string."); value_it->Value>().emplace( - key.Value(), input_value); + key.ValueString(), input_value); break; } // end switch over Aggregation::Op enum } // end loop over all aggregations diff --git a/src/query/typed_value.cpp b/src/query/typed_value.cpp index 70cefb9c0..8d679100c 100644 --- a/src/query/typed_value.cpp +++ b/src/query/typed_value.cpp @@ -307,7 +307,7 @@ std::ostream &operator<<(std::ostream &os, const TypedValue &value) { case TypedValue::Type::Double: return os << value.Value(); case TypedValue::Type::String: - return os << value.Value(); + return os << value.ValueString(); case TypedValue::Type::List: os << "["; utils::PrintIterable(os, value.ValueList()); @@ -580,7 +580,7 @@ TypedValue operator<(const TypedValue &a, const TypedValue &b) { throw TypedValueException("Invalid 'less' operand types({} + {})", a.type(), b.type()); } else { - return TypedValue(a.Value() < b.Value(), + return TypedValue(a.ValueString() < b.ValueString(), a.GetMemoryResource()); } } @@ -615,7 +615,7 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) { case TypedValue::Type::Double: return TypedValue(ToDouble(a) == ToDouble(b), a.GetMemoryResource()); case TypedValue::Type::String: - return TypedValue(a.Value() == b.Value(), + return TypedValue(a.ValueString() == b.ValueString(), a.GetMemoryResource()); case TypedValue::Type::Vertex: return TypedValue(a.Value() == b.Value(), @@ -680,7 +680,7 @@ TypedValue operator!(const TypedValue &a) { * @return A string. */ std::string ValueToString(const TypedValue &value) { - if (value.IsString()) return value.Value(); + if (value.IsString()) return value.ValueString(); if (value.IsInt()) return std::to_string(value.Value()); if (value.IsDouble()) return fmt::format("{}", value.Value()); // unsupported situations @@ -894,7 +894,7 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const { case TypedValue::Type::Double: return std::hash{}(value.Value()); case TypedValue::Type::String: - return std::hash{}(value.Value()); + return std::hash{}(value.ValueString()); case TypedValue::Type::List: { return utils::FnvCollection{}( value.ValueList()); diff --git a/tests/unit/distributed_interpretation.cpp b/tests/unit/distributed_interpretation.cpp index 2cde30432..721397a5a 100644 --- a/tests/unit/distributed_interpretation.cpp +++ b/tests/unit/distributed_interpretation.cpp @@ -153,7 +153,7 @@ TEST_F(DistributedInterpretationTest, RemoteExpandTest2) { std::vector row; row.reserve(res.size()); for (const auto &col : res) { - row.push_back(col.Value()); + row.push_back(col.ValueString()); } got.push_back(row); } diff --git a/tests/unit/interpreter.cpp b/tests/unit/interpreter.cpp index be8b4e152..b47be1ded 100644 --- a/tests/unit/interpreter.cpp +++ b/tests/unit/interpreter.cpp @@ -111,7 +111,7 @@ TEST_F(InterpreterTest, Parameters) { auto stream = Interpret("RETURN $2 + $`a b`", {{"2", "da"}, {"a b", "ne"}}); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), "dane"); + ASSERT_EQ(stream.GetResults()[0][0].ValueString(), "dane"); } { // Non-primitive literal. diff --git a/tests/unit/typed_value.cpp b/tests/unit/typed_value.cpp index 6b708db51..f59db3b01 100644 --- a/tests/unit/typed_value.cpp +++ b/tests/unit/typed_value.cpp @@ -82,8 +82,8 @@ TEST(TypedValue, CreationValues) { EXPECT_EQ(TypedValue(true).Value(), true); EXPECT_EQ(TypedValue(false).Value(), false); - EXPECT_EQ(TypedValue(std::string("bla")).Value(), "bla"); - EXPECT_EQ(TypedValue("bla2").Value(), "bla2"); + EXPECT_EQ(TypedValue(std::string("bla")).ValueString(), "bla"); + EXPECT_EQ(TypedValue("bla2").ValueString(), "bla2"); EXPECT_EQ(TypedValue(55).Value(), 55); @@ -298,15 +298,15 @@ TEST_F(TypedValueArithmeticTest, Sum) { // sum of props of the same type EXPECT_EQ((TypedValue(2) + TypedValue(3)).Value(), 5); EXPECT_FLOAT_EQ((TypedValue(2.5) + TypedValue(1.25)).Value(), 3.75); - EXPECT_EQ((TypedValue("one") + TypedValue("two")).Value(), + EXPECT_EQ((TypedValue("one") + TypedValue("two")).ValueString(), "onetwo"); // sum of string and numbers - EXPECT_EQ((TypedValue("one") + TypedValue(1)).Value(), "one1"); - EXPECT_EQ((TypedValue(1) + TypedValue("one")).Value(), "1one"); - EXPECT_EQ((TypedValue("one") + TypedValue(3.2)).Value(), + EXPECT_EQ((TypedValue("one") + TypedValue(1)).ValueString(), "one1"); + EXPECT_EQ((TypedValue(1) + TypedValue("one")).ValueString(), "1one"); + EXPECT_EQ((TypedValue("one") + TypedValue(3.2)).ValueString(), "one3.2"); - EXPECT_EQ((TypedValue(3.2) + TypedValue("one")).Value(), + EXPECT_EQ((TypedValue(3.2) + TypedValue("one")).ValueString(), "3.2one"); std::vector in = {1, 2, true, "a"}; std::vector out1 = {2, 1, 2, true, "a"}; diff --git a/tools/tests/mg_recovery_check.cpp b/tools/tests/mg_recovery_check.cpp index 26bedc406..707a587f3 100644 --- a/tools/tests/mg_recovery_check.cpp +++ b/tools/tests/mg_recovery_check.cpp @@ -49,7 +49,7 @@ TEST_F(RecoveryTest, TestPropertyNull) { for (const auto &vertex : dba.Vertices(dba.Label("Comment"), false)) { auto id_prop = query::TypedValue(vertex.PropsAt(dba.Property("id"))); auto browser = query::TypedValue(vertex.PropsAt(dba.Property("browser"))); - if (id_prop.IsString() && id_prop.Value() == "2") { + if (id_prop.IsString() && id_prop.ValueString() == "2") { EXPECT_FALSE(found); found = true; EXPECT_TRUE(browser.IsNull()); @@ -73,9 +73,9 @@ TEST_F(RecoveryTest, TestQuote) { for (const auto &vertex : dba.Vertices(dba.Label("Comment"), false)) { auto id_prop = query::TypedValue(vertex.PropsAt(dba.Property("id"))); auto country = query::TypedValue(vertex.PropsAt(dba.Property("country"))); - if (id_prop.IsString() && id_prop.Value() == "1") { + if (id_prop.IsString() && id_prop.ValueString() == "1") { EXPECT_TRUE(country.IsString()); - EXPECT_EQ(country.Value(), "United Kingdom"); + EXPECT_EQ(country.ValueString(), "United Kingdom"); } } }