-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support assigning nested collections via templated API #7478
Conversation
eef764f
to
e6fae70
Compare
Pull Request Test Coverage Report for Build jorgen.edelbo_192Details
💛 - Coveralls |
e6fae70
to
9eaf6c3
Compare
f3563f3
to
768ab8a
Compare
} // namespace object_store | ||
} // namespace realm | ||
|
||
#include <realm/object-store/list.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this include here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the mutural dependency between Dictionary and List, it must be included after the definition of Dictionary.
@@ -156,6 +156,13 @@ void Collection::validate_embedded(Context& ctx, T&& value, CreatePolicy policy) | |||
throw IllegalOperation(util::format("Cannot add an existing managed embedded object to a %1.", type_name())); | |||
} | |||
|
|||
// Dummy implementation to satisfy StringifyingContext | |||
inline std::ostream& operator<<(std::ostream& out, const Collection&) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in a test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -178,6 +184,41 @@ inline Obj Dictionary::get<Obj>(StringData key) const | |||
return get_object(key); | |||
} | |||
|
|||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an ODR violation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched bact to just using a lambda.
attr_changed = !new_val.is_same_type(*old_val); | ||
} | ||
|
||
attr_changed = attr_changed || new_val != *old_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr_changed is always false here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that?
sync_config.schema_version = 0; | ||
server.start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to be delaying starting the server here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test has been run for a long time. I just tried to make it work, but did not really succeed. The test is still not run.
} | ||
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a proper wait rather than hoping that it's sleeping long enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just another attempt to get the test to work - but clearly not the right one.
src/realm/object-store/list.hpp
Outdated
if (m_type == PropertyType::Mixed) { | ||
Mixed new_val = ctx.template unbox<Mixed>(value, policy); | ||
if (new_val.is_type(type_Dictionary)) { | ||
set_collection(list_ndx, CollectionType::Dictionary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be a bunch of duplicated code between List and Dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar, but not the same.
f70bf10
to
0f798cb
Compare
@tgoyne is anything blocking this now? |
b56f162 eliminates the circular dependency that requires doing weird things with includes and extracts the easy-to-extract bits of duplicated logic. |
@tgoyne Probably a better idea to collect all the templates in object_accessor.hpp - although they are collection accessors. I am not sure your changes works in all cases - I will have to make some more tests. |
d37888b
to
e71f412
Compare
@tgoyne - your turn |
{ | ||
return dispatch([&](auto t) { | ||
return ctx.box(this->get<std::decay_t<decltype(*t)>>(row_ndx)); | ||
using U = std::decay_t<decltype(*t)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this change here is causing a test to fail, in line 428 when the value is an object within an enumeration, with this error
realm::InvalidTableRef: null
trying to call the Mixed constructor, I don't know why
Changing line 428 to return ctx.box(this->get<std::decay_t<decltype(*t)>>(ndx));
doesn't call the Mixed constructor and doesn't fails
if constexpr (std::is_same_v<U, Obj>) { | ||
ObjKey old_key; | ||
if (auto old_value = dict().try_get(key)) { | ||
old_key = old_value->get_link().get_obj_key(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a crash when trying to add a Realm Object into a dictionary of realm objects. This tries to read the mixed values from the dictionary when is actually a dictionary of objects, this crash when trying to get the type of the mixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!, Changes are working fine with CIM implementation
What, How & Why?
☑️ ToDos
bindgen/spec.yml
, if public C++ API changed