Skip to content

Commit

Permalink
Allow non-embedded links in asymmetric objects
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed Sep 15, 2023
1 parent a3717e4 commit 9d1a1a6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 23 deletions.
7 changes: 0 additions & 7 deletions src/realm/object-store/object_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,6 @@ static void validate_property(Schema const& schema, ObjectSchema const& parent_o
object_name, prop.name, prop.object_type);
return;
}
if (parent_object_schema.table_type == ObjectSchema::ObjectType::TopLevelAsymmetric &&
it->table_type != ObjectSchema::ObjectType::Embedded) {
exceptions.emplace_back(
"Asymmetric table with property '%1.%2' of type '%3' cannot have a non-embedded object type.",
object_name, prop.name, string_for_property_type(prop.type));
return;
}
if (it->table_type == ObjectSchema::ObjectType::TopLevelAsymmetric) {
exceptions.emplace_back("Property '%1.%2' of type '%3' cannot be a link to an asymmetric object.",
object_name, prop.name, string_for_property_type(prop.type));
Expand Down
4 changes: 0 additions & 4 deletions src/realm/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@ ColKey Table::add_column(Table& target, StringData name)
Group* target_group = target.get_parent_group();
REALM_ASSERT_RELEASE(origin_group && target_group);
REALM_ASSERT_RELEASE(origin_group == target_group);
// Only links to embedded objects are allowed.
if (is_asymmetric() && !target.is_embedded()) {
throw IllegalOperation("Object property not supported in asymmetric table");
}
// Incoming links from an asymmetric table are not allowed.
if (target.is_asymmetric()) {
throw IllegalOperation("Ephemeral objects not supported");
Expand Down
12 changes: 0 additions & 12 deletions test/object-store/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,6 @@ TEST_CASE("Schema") {
"Property 'object.link' of type 'object' cannot be a link to an asymmetric object."));
}

SECTION("rejects link properties with asymmetric origin object") {
Schema schema = {
{"object",
ObjectSchema::ObjectType::TopLevelAsymmetric,
{{"link", PropertyType::Object | PropertyType::Nullable, "link target"}}},
{"link target", {{"value", PropertyType::Int}}},
};
REQUIRE_EXCEPTION(schema.validate(SchemaValidationMode::SyncFLX), SchemaValidationFailed,
ContainsSubstring("Asymmetric table with property 'object.link' of type 'object' "
"cannot have a non-embedded object type."));
}

SECTION("allow embedded objects with asymmetric sync") {
Schema schema = {
{"object",
Expand Down

0 comments on commit 9d1a1a6

Please sign in to comment.