Add support for Weak/Strong links aka Cascading deletes#622
Conversation
|
|
||
| #include "util/tagged_bool.hpp" | ||
|
|
||
| #include <string> |
There was a problem hiding this comment.
This include was previously in the correct place.
There was a problem hiding this comment.
I'm not entirely sure why, but If this is not here I get:
In file included from /Users/cm/Realm/realm-object-store/src/property.hpp:24:
/Users/cm/Realm/realm-object-store/CMakeFiles/realm-core-5.0.1/include/realm/data_type.hpp:27:9: error: unknown type name 'int64_t'
typedef int64_t Int;
There was a problem hiding this comment.
data_types.hpp needs to include <cstdint>
|
|
||
| // Return the underlying LinkType. Only useful for Object or Array properties. | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wreturn-type" |
There was a problem hiding this comment.
Giving Relationship a backing type of bool eliminates the need for this.
| { | ||
| } | ||
|
|
||
| inline Property::Property(std::string name, PropertyType type, |
There was a problem hiding this comment.
It is being used by tests and not having it results in:
Undefined symbols for architecture x86_64:
"realm::Property::Property(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, realm::PropertyType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
____C_A_T_C_H____T_E_S_T____0() in list.cpp.o
____C_A_T_C_H____T_E_S_T____3() in migrations.cpp.o
____C_A_T_C_H____T_E_S_T____111() in migrations.cpp.o
____C_A_T_C_H____T_E_S_T____134() in migrations.cpp.o
____C_A_T_C_H____T_E_S_T____0() in object.cpp.o
____C_A_T_C_H____T_E_S_T____3() in object_store.cpp.o
____C_A_T_C_H____T_E_S_T____102() in results.cpp.o
There was a problem hiding this comment.
It is functionally identical to the three-argument version with a default value for the third argument (i.e. what previously existed).
There was a problem hiding this comment.
Those was changed as well, these constructors have no default values anymore as having two 3-argument constructors with different defaults is ambiguous. So there is now a constructor for creating backlinks (with a string default value) and one for creating normal links (with a relationship default value)
There was a problem hiding this comment.
Having Property(std::string name, PropertyType type, std::string object_type, std::string link_origin_property_name=""); and Property(std::string name, PropertyType type, std::string object_type, Relationship relationship); is not ambiguous.
There was a problem hiding this comment.
Ah, like that. No, your right.
There was a problem hiding this comment.
2-arg constructor has been removed
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wreturn-type" | ||
| LinkType link_type() const { | ||
| switch(relationship) { |
| else if (current_prop.requires_index()) { | ||
| changes.emplace_back(schema_change::RemoveIndex{&existing_schema, ¤t_prop}); | ||
| } | ||
| if(target_prop->relationship != current_prop.relationship) { |
| // See Descriptor::set_link_type() in Core (descriptor.hpp) for an extended explanation of the exact semantics. | ||
|
|
||
| namespace realm { | ||
| class TestHelper { |
There was a problem hiding this comment.
There's no reason to put these functions in a class.
| @@ -0,0 +1,303 @@ | |||
| //////////////////////////////////////////////////////////////////////////// | |||
There was a problem hiding this comment.
This entire file appears to just be testing core functionality, and should be part of core's test suite instead.
| return schema; | ||
| } | ||
|
|
||
| Schema set_relationship(Schema schema, StringData object_name, StringData property_name, Relationship new_relationship_type) { |
|
All comments addressed |
|
Currently, Sync will crash with |
|
Destructive changes always caused "bad changeset received", how is this any different? |
|
The problem is not that you cannot make existing links strong, but rather that sync does not support strong links at all. |
|
Cascading deletes are now (somewhat) supported via embedded objects and it's unlikely sync will ever support strong links, so closing this. |
This PR exposes cores concept of Weak/Strong links in the Object Store schema using the
Relationship::Strongparameter when creating link properties. This can be used to implement cascading deletes.Semantics:
Java PR using this is here: realm/realm-java#5678