-
Notifications
You must be signed in to change notification settings - Fork 577
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
Basic data migrations #383
Conversation
869174c
to
8f07cd8
Compare
@appden ready for review now. |
@@ -243,11 +245,12 @@ inline typename T::Function Realm<T>::create_constructor(ContextType ctx) { | |||
} | |||
|
|||
template<typename T> | |||
void Realm<T>::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { | |||
void Realm<T>::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { |
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.
Accidental whitespace added
@@ -363,6 +378,12 @@ void Realm<T>::get_schema_version(ContextType ctx, ObjectType object, ReturnValu | |||
} | |||
|
|||
template<typename T> | |||
void Realm<T>::get_schema(ContextType ctx, ObjectType object, ReturnValue &return_value) { | |||
auto schema = get_internal<T, RealmClass<T>>(object)->get()->config().schema.get(); |
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.
It doesn't really matter, but I don't think the ->get()
part is necessary.
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.
it is necessary
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 get it now, since it's a pointer to a shared_ptr
|
||
static const String type_string = "type"; | ||
const std::string type = property.type != PropertyTypeArray ? string_for_property_type(property.type) : "list"; | ||
Object::set_property(ctx, object, type_string, Value::from_string(ctx, type)); |
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 would prefer if the type
be the objectType
for type == "object"
, since we encourage that usage in our documentation to avoid confusion caused by objectType
meaning two possible things.
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 makes code that is evaluating the schema much nastier - what you suggest would make it very difficult to check if something is an object type.
Looks good 👍 |
Closes #333
Allows manual copying/renaming of properties without having to do an extra migrations. Design also supports stepwise migrations.
I think we should consider shipping this improvement without full support for property renames or schema access during migrations, as this eliminates the biggest pain points and current limitations.