Add ErrorCode to SHARD_ERROR macro

This commit is contained in:
jbajic 2022-11-22 14:05:04 +01:00
parent 2a6dc7bb93
commit 5717dfb165
10 changed files with 130 additions and 127 deletions

View File

@ -112,7 +112,7 @@ BoltResult<communication::bolt::Path> ToBoltPath(const query::v2::accessors::Pat
const msgs::ShardRequestManagerInterface * /*shard_request_manager*/,
storage::v3::View /*view*/) {
// TODO(jbajic) Fix bolt communication
return {SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)};
return {SHARD_ERROR(ErrorCode::DELETED_OBJECT)};
}
BoltResult<Value> ToBoltValue(const query::v2::TypedValue &value,

View File

@ -57,11 +57,11 @@ const VertexId &EdgeAccessor::ToVertex() const { return to_vertex_; }
ShardResult<PropertyValue> EdgeAccessor::SetProperty(PropertyId property, const PropertyValue &value) {
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception;
if (!config_.properties_on_edges) return SHARD_ERROR(common::ErrorCode::PROPERTIES_DISABLED);
if (!config_.properties_on_edges) return SHARD_ERROR(ErrorCode::PROPERTIES_DISABLED);
if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (edge_.ptr->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (edge_.ptr->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto current_value = edge_.ptr->properties.GetProperty(property);
// We could skip setting the value if the previous one is the same to the new
@ -77,11 +77,11 @@ ShardResult<PropertyValue> EdgeAccessor::SetProperty(PropertyId property, const
}
ShardResult<std::map<PropertyId, PropertyValue>> EdgeAccessor::ClearProperties() {
if (!config_.properties_on_edges) return SHARD_ERROR(common::ErrorCode::PROPERTIES_DISABLED);
if (!config_.properties_on_edges) return SHARD_ERROR(ErrorCode::PROPERTIES_DISABLED);
if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (edge_.ptr->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (edge_.ptr->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto properties = edge_.ptr->properties.Properties();
for (const auto &property : properties) {
@ -129,8 +129,8 @@ ShardResult<PropertyValue> EdgeAccessor::GetProperty(PropertyId property, View v
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return std::move(value);
}
@ -175,8 +175,8 @@ ShardResult<std::map<PropertyId, PropertyValue>> EdgeAccessor::Properties(View v
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return std::move(properties);
}

View File

@ -42,7 +42,11 @@ struct ShardError {
};
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define SHARD_ERROR(...) memgraph::storage::v3::ShardError(__VA_ARGS__, std::experimental::source_location::current())
#define SHARD_ERROR(...) \
({ \
using ErrorCode = memgraph::common::ErrorCode; \
memgraph::storage::v3::ShardError(__VA_ARGS__, std::experimental::source_location::current()); \
})
template <class TValue>
using ShardResult = utils::BasicResult<ShardError, TValue>;

View File

@ -31,14 +31,14 @@ std::optional<ShardError> SchemaValidator::ValidateVertexCreate(
// Schema on primary label
const auto *schema = schemas_->GetSchema(primary_label);
if (schema == nullptr) {
return SHARD_ERROR(common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL,
return SHARD_ERROR(ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL,
fmt::format("Schema not defined for label :{}", name_id_mapper_->IdToName(primary_label)));
}
// Is there another primary label among secondary labels
for (const auto &secondary_label : labels) {
if (schemas_->GetSchema(secondary_label)) {
return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY,
return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY,
fmt::format("Cannot add label :{}, since it is defined as a primary label",
name_id_mapper_->IdToName(secondary_label)));
}
@ -46,7 +46,7 @@ std::optional<ShardError> SchemaValidator::ValidateVertexCreate(
// Quick size check
if (schema->second.size() != primary_properties.size()) {
return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED,
return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED,
fmt::format("Not all primary properties have been specified for :{} vertex",
name_id_mapper_->IdToName(primary_label)));
}
@ -88,7 +88,7 @@ std::optional<ShardError> SchemaValidator::ValidatePropertyUpdate(const LabelId
std::optional<ShardError> SchemaValidator::ValidateLabelUpdate(const LabelId label) const {
const auto *schema = schemas_->GetSchema(label);
if (schema) {
return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL,
return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL,
fmt::format("Cannot add/remove primary label :{}", name_id_mapper_->IdToName(label)));
}
return std::nullopt;

View File

@ -364,7 +364,7 @@ ShardResult<VertexAccessor> Shard::Accessor::CreateVertexAndValidate(
VertexAccessor vertex_acc{&it->vertex, transaction_, &shard_->indices_, config_, shard_->vertex_validator_};
if (!inserted) {
return SHARD_ERROR(common::ErrorCode::VERTEX_ALREADY_INSERTED);
return SHARD_ERROR(ErrorCode::VERTEX_ALREADY_INSERTED);
}
MG_ASSERT(it != acc.end(), "Invalid Vertex accessor!");
@ -401,14 +401,13 @@ ShardResult<std::optional<VertexAccessor>> Shard::Accessor::DeleteVertex(VertexA
"accessor when deleting a vertex!");
auto *vertex_ptr = vertex->vertex_;
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_ptr->deleted) {
return std::optional<VertexAccessor>{};
}
if (!vertex_ptr->in_edges.empty() || !vertex_ptr->out_edges.empty())
return SHARD_ERROR(common::ErrorCode::VERTEX_HAS_EDGES);
if (!vertex_ptr->in_edges.empty() || !vertex_ptr->out_edges.empty()) return SHARD_ERROR(ErrorCode::VERTEX_HAS_EDGES);
CreateAndLinkDelta(transaction_, vertex_ptr, Delta::RecreateObjectTag());
vertex_ptr->deleted = true;
@ -430,7 +429,7 @@ ShardResult<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>>
std::vector<Vertex::EdgeLink> out_edges;
{
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_ptr->deleted) return std::optional<ReturnType>{};
@ -471,7 +470,7 @@ ShardResult<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>>
// vertex. Some other transaction could have modified the vertex in the
// meantime if we didn't have any edges to delete.
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
MG_ASSERT(!vertex_ptr->deleted, "Invalid database state!");
@ -508,12 +507,12 @@ ShardResult<EdgeAccessor> Shard::Accessor::CreateEdge(VertexId from_vertex_id, V
}
if (from_is_local) {
if (!PrepareForWrite(transaction_, from_vertex)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (from_vertex->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!PrepareForWrite(transaction_, from_vertex)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (from_vertex->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
}
if (to_is_local && to_vertex != from_vertex) {
if (!PrepareForWrite(transaction_, to_vertex)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (to_vertex->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!PrepareForWrite(transaction_, to_vertex)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (to_vertex->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
}
EdgeRef edge(gid);
@ -568,13 +567,13 @@ ShardResult<std::optional<EdgeAccessor>> Shard::Accessor::DeleteEdge(VertexId fr
if (from_is_local) {
if (!PrepareForWrite(transaction_, from_vertex)) {
return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
}
MG_ASSERT(!from_vertex->deleted, "Invalid database state!");
}
if (to_is_local && to_vertex != from_vertex) {
if (!PrepareForWrite(transaction_, to_vertex)) {
return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
}
MG_ASSERT(!to_vertex->deleted, "Invalid database state!");
}

View File

@ -83,9 +83,9 @@ bool VertexAccessor::IsVisible(View view) const {
ShardResult<bool> VertexAccessor::AddLabel(LabelId label) {
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception;
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
if (std::find(vertex_->labels.begin(), vertex_->labels.end(), label) != vertex_->labels.end()) return false;
@ -104,9 +104,9 @@ ShardResult<bool> VertexAccessor::AddLabelAndValidate(LabelId label) {
}
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception;
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
if (std::find(vertex_->labels.begin(), vertex_->labels.end(), label) != vertex_->labels.end()) return false;
@ -120,9 +120,9 @@ ShardResult<bool> VertexAccessor::AddLabelAndValidate(LabelId label) {
}
ShardResult<bool> VertexAccessor::RemoveLabel(LabelId label) {
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto it = std::find(vertex_->labels.begin(), vertex_->labels.end(), label);
if (it == vertex_->labels.end()) return false;
@ -139,9 +139,9 @@ ShardResult<bool> VertexAccessor::RemoveLabelAndValidate(LabelId label) {
return {*maybe_violation_error};
}
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto it = std::find(vertex_->labels.begin(), vertex_->labels.end(), label);
if (it == vertex_->labels.end()) return false;
@ -197,8 +197,8 @@ ShardResult<bool> VertexAccessor::HasLabel(LabelId label, View view) const {
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return has_label;
}
@ -267,17 +267,17 @@ ShardResult<std::vector<LabelId>> VertexAccessor::Labels(View view) const {
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return std::move(labels);
}
ShardResult<PropertyValue> VertexAccessor::SetProperty(PropertyId property, const PropertyValue &value) {
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception;
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto current_value = vertex_->properties.GetProperty(property);
// We could skip setting the value if the previous one is the same to the new
@ -323,10 +323,10 @@ ShardResult<void> VertexAccessor::CheckVertexExistence(View view) const {
}
});
if (!exists) {
return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
}
if (!for_deleted_ && deleted) {
return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
}
return {};
}
@ -338,11 +338,11 @@ ShardResult<PropertyValue> VertexAccessor::SetPropertyAndValidate(PropertyId pro
utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception;
if (!PrepareForWrite(transaction_, vertex_)) {
return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
}
if (vertex_->deleted) {
return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
}
auto current_value = vertex_->properties.GetProperty(property);
@ -361,9 +361,9 @@ ShardResult<PropertyValue> VertexAccessor::SetPropertyAndValidate(PropertyId pro
}
ShardResult<std::map<PropertyId, PropertyValue>> VertexAccessor::ClearProperties() {
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR);
if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR);
if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
auto properties = vertex_->properties.Properties();
for (const auto &property : properties) {
@ -441,8 +441,8 @@ ShardResult<PropertyValue> VertexAccessor::GetProperty(PropertyId property, View
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return std::move(value);
}
@ -491,8 +491,8 @@ ShardResult<std::map<PropertyId, PropertyValue>> VertexAccessor::Properties(View
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return std::move(properties);
}
@ -563,8 +563,8 @@ ShardResult<std::vector<EdgeAccessor>> VertexAccessor::InEdges(View view, const
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
std::vector<EdgeAccessor> ret;
if (in_edges.empty()) {
return ret;
@ -643,8 +643,8 @@ ShardResult<std::vector<EdgeAccessor>> VertexAccessor::OutEdges(View view, const
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
std::vector<EdgeAccessor> ret;
if (out_edges.empty()) {
return ret;
@ -690,8 +690,8 @@ ShardResult<size_t> VertexAccessor::InDegree(View view) const {
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return degree;
}
@ -727,8 +727,8 @@ ShardResult<size_t> VertexAccessor::OutDegree(View view) const {
break;
}
});
if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT);
if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT);
if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT);
return degree;
}

View File

@ -580,7 +580,7 @@ TEST_P(StorageV3, VertexDeleteSerializationError) {
EXPECT_EQ(CountVertices(acc2, View::NEW), 1U);
auto res = acc2.DeleteVertex(&*vertex);
ASSERT_TRUE(res.HasError());
ASSERT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR));
ASSERT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR));
EXPECT_EQ(CountVertices(acc2, View::OLD), 1U);
EXPECT_EQ(CountVertices(acc2, View::NEW), 1U);
acc2.AdvanceCommand();
@ -711,20 +711,20 @@ TEST_P(StorageV3, VertexDeleteLabel) {
// Check whether label 5 exists
ASSERT_FALSE(vertex->HasLabel(label5, View::OLD).GetValue());
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::OLD)->size(), 0);
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Try to add the label
{
auto ret = vertex->AddLabelAndValidate(label5);
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
// Try to remove the label
{
auto ret = vertex->RemoveLabelAndValidate(label5);
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
acc.Abort();
@ -779,33 +779,33 @@ TEST_P(StorageV3, VertexDeleteLabel) {
// Check whether label 5 exists
ASSERT_TRUE(vertex->HasLabel(label5, View::OLD).GetValue());
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
{
auto labels = vertex->Labels(View::OLD).GetValue();
ASSERT_EQ(labels.size(), 1);
ASSERT_EQ(labels[0], label5);
}
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Advance command
acc.AdvanceCommand();
// Check whether label 5 exists
ASSERT_EQ(vertex->HasLabel(label5, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->HasLabel(label5, View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Try to add the label
{
auto ret = vertex->AddLabelAndValidate(label5);
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
// Try to remove the label
{
auto ret = vertex->RemoveLabelAndValidate(label5);
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
acc.Abort();
@ -855,14 +855,14 @@ TEST_P(StorageV3, VertexDeleteProperty) {
// Check whether label 5 exists
ASSERT_TRUE(vertex->GetProperty(property5, View::OLD)->IsNull());
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::OLD)->size(), 0);
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Try to set the property5
{
auto ret = vertex->SetPropertyAndValidate(property5, PropertyValue("haihai"));
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
acc.Abort();
@ -918,27 +918,27 @@ TEST_P(StorageV3, VertexDeleteProperty) {
// Check whether property 5 exists
ASSERT_EQ(vertex->GetProperty(property5, View::OLD)->ValueString(), "nandare");
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
{
auto properties = vertex->Properties(View::OLD).GetValue();
ASSERT_EQ(properties.size(), 1);
ASSERT_EQ(properties[property5].ValueString(), "nandare");
}
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Advance command
acc.AdvanceCommand();
// Check whether property 5 exists
ASSERT_EQ(vertex->GetProperty(property5, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->GetProperty(property5, View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
// Try to set the property
{
auto ret = vertex->SetPropertyAndValidate(property5, PropertyValue("haihai"));
AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT));
}
acc.Abort();
@ -1371,7 +1371,7 @@ TEST_P(StorageV3, VertexLabelSerializationError) {
{
auto res = vertex->AddLabelAndValidate(label1);
AssertShardErrorEqual(res, SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR));
AssertShardErrorEqual(res, SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR));
}
}
@ -1865,7 +1865,7 @@ TEST_P(StorageV3, VertexPropertySerializationError) {
{
auto res = vertex->SetPropertyAndValidate(property2, PropertyValue("nandare"));
AssertShardErrorEqual(res, SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR));
AssertShardErrorEqual(res, SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR));
}
}
@ -2255,14 +2255,14 @@ TEST_P(StorageV3, VertexNonexistentLabelPropertyEdgeAPI) {
auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{0}, {});
// Check state before (OLD view).
ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
// Check state before (NEW view).
ASSERT_EQ(vertex.Labels(View::NEW)->size(), 0);
@ -2282,14 +2282,14 @@ TEST_P(StorageV3, VertexNonexistentLabelPropertyEdgeAPI) {
.HasValue());
// Check state after (OLD view).
ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
// Check state after (NEW view).
ASSERT_EQ(vertex.Labels(View::NEW)->size(), 1);
@ -2663,25 +2663,25 @@ TEST_P(StorageV3, TestCreateVertexAndValidate) {
auto acc = store.Access(GetNextHlc());
auto vertex = acc.CreateVertexAndValidate({primary_label}, {PropertyValue{0}}, {});
ASSERT_TRUE(vertex.HasError());
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
}
{
auto acc = store.Access(GetNextHlc());
auto vertex = acc.CreateVertexAndValidate({primary_label}, {PropertyValue{0}}, {});
ASSERT_TRUE(vertex.HasError());
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
}
{
auto acc = store.Access(GetNextHlc());
auto vertex = acc.CreateVertexAndValidate({}, {}, {});
ASSERT_TRUE(vertex.HasError());
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED));
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED));
}
{
auto acc = store.Access(GetNextHlc());
auto vertex = acc.CreateVertexAndValidate({}, {PropertyValue{"test"}}, {});
ASSERT_TRUE(vertex.HasError());
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
}
}
} // namespace memgraph::storage::v3::tests

View File

@ -3242,7 +3242,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) {
{
auto ret = acc.DeleteVertex(&vertex_from.value());
ASSERT_TRUE(ret.HasError());
ASSERT_EQ(ret.GetError(), SHARD_ERROR(common::ErrorCode::VERTEX_HAS_EDGES));
ASSERT_EQ(ret.GetError(), SHARD_ERROR(ErrorCode::VERTEX_HAS_EDGES));
}
// Detach delete vertex
@ -3255,8 +3255,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) {
// Check edges
ASSERT_EQ(vertex_from->InEdges(View::OLD)->size(), 0);
ASSERT_EQ(*vertex_from->InDegree(View::OLD), 0);
ASSERT_EQ(vertex_from->InEdges(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->InDegree(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->InEdges(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->InDegree(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
{
auto ret = vertex_from->OutEdges(View::OLD);
ASSERT_TRUE(ret.HasValue());
@ -3269,8 +3269,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) {
ASSERT_EQ(e.FromVertex(), from_id);
ASSERT_EQ(e.ToVertex(), to_id);
}
ASSERT_EQ(vertex_from->OutEdges(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->OutDegree(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->OutEdges(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
ASSERT_EQ(vertex_from->OutDegree(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT));
{
auto ret = vertex_to->InEdges(View::OLD);
ASSERT_TRUE(ret.HasValue());

View File

@ -188,43 +188,43 @@ TEST_F(SchemaValidatorTest, TestSchemaValidateVertexCreate) {
{
const auto schema_violation = schema_validator.ValidateVertexCreate(NameToLabel("test"), {}, {PropertyValue(1)});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL));
}
{
const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED));
}
// Validate wrong secondary label
{
const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label1}, {PropertyValue("test")});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
}
{
const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label2}, {PropertyValue("test")});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
}
// Validate wrong property type
{
const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {}, {PropertyValue(1)});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
}
{
const auto schema_violation =
schema_validator.ValidateVertexCreate(label2, {}, {PropertyValue("test"), PropertyValue(12), PropertyValue(1)});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
}
{
const auto wrong_prop = PropertyValue(TemporalData(TemporalType::Date, 1234));
const auto schema_violation =
schema_validator.ValidateVertexCreate(label2, {}, {PropertyValue("test"), PropertyValue(12), wrong_prop});
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE));
}
// Passing validations
EXPECT_EQ(schema_validator.ValidateVertexCreate(label1, {}, {PropertyValue("test")}), std::nullopt);
@ -246,12 +246,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdate) {
{
const auto schema_violation = schema_validator.ValidatePropertyUpdate(label1, prop_string);
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
}
{
const auto schema_violation = schema_validator.ValidatePropertyUpdate(label2, prop_duration);
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
}
EXPECT_EQ(schema_validator.ValidatePropertyUpdate(label1, prop_int), std::nullopt);
EXPECT_EQ(schema_validator.ValidatePropertyUpdate(label1, prop_duration), std::nullopt);
@ -263,12 +263,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdateLabel) {
{
const auto schema_violation = schema_validator.ValidateLabelUpdate(label1);
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
}
{
const auto schema_violation = schema_validator.ValidateLabelUpdate(label2);
ASSERT_NE(schema_violation, std::nullopt);
EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
}
EXPECT_EQ(schema_validator.ValidateLabelUpdate(NameToLabel("test")), std::nullopt);
}

View File

@ -77,7 +77,7 @@ TEST_F(StorageV3Accessor, TestPrimaryLabel) {
ASSERT_TRUE(vertex.PrimaryLabel(View::OLD).HasError());
const auto error_primary_label = vertex.PrimaryLabel(View::OLD).GetError();
ASSERT_FALSE(vertex.PrimaryLabel(View::NEW).HasError());
EXPECT_EQ(error_primary_label, SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT));
EXPECT_EQ(error_primary_label, SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT));
}
{
auto acc = storage.Access(GetNextHlc());
@ -128,7 +128,7 @@ TEST_F(StorageV3Accessor, TestAddLabels) {
const auto label1 = NameToLabelId("label");
auto vertex = acc.CreateVertexAndValidate({label1}, {PropertyValue{2}}, {});
ASSERT_TRUE(vertex.HasError());
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY));
}
{
auto acc = storage.Access(GetNextHlc());
@ -137,7 +137,7 @@ TEST_F(StorageV3Accessor, TestAddLabels) {
ASSERT_TRUE(vertex.HasValue());
const auto schema_violation = vertex->AddLabelAndValidate(label1);
ASSERT_TRUE(schema_violation.HasError());
EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
}
}
@ -181,7 +181,7 @@ TEST_F(StorageV3Accessor, TestRemoveLabels) {
auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{2});
const auto res1 = vertex.RemoveLabelAndValidate(primary_label);
ASSERT_TRUE(res1.HasError());
EXPECT_EQ(res1.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
EXPECT_EQ(res1.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL));
}
}
@ -200,14 +200,14 @@ TEST_F(StorageV3Accessor, TestSetKeysAndProperties) {
auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{1});
const auto res = vertex.SetPropertyAndValidate(primary_property, PropertyValue(1));
ASSERT_TRUE(res.HasError());
EXPECT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
EXPECT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
}
{
auto acc = storage.Access(GetNextHlc());
auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{2});
const auto res = vertex.SetPropertyAndValidate(primary_property, PropertyValue());
ASSERT_TRUE(res.HasError());
EXPECT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
EXPECT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY));
}
}