-
Notifications
You must be signed in to change notification settings - Fork 170
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
Add get local schema version to the C-API #7873
Conversation
Opening in Immutable mode can fail catastrophically if it's done while another process is writing to the file, as it doesn't create a read lock. Instead it needs to modify the config to unset the sync config and set |
…rieve_persisted_schema_version
8023729
to
cd33039
Compare
src/realm.h
Outdated
/** | ||
* Get the schema version for this realm at the path. | ||
* | ||
* This function cannot fail. |
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 opens (and possibly creates) a Realm file, which can fail.
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.
Yep left over…
} | ||
|
||
return wrap_err([&]() { | ||
auto realm = new shared_realm{Realm::get_shared_realm(conf)}; |
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's no reason to wrap this in an extra shared_realm
since it isn't returned to the caller.
cd33039
to
8830dca
Compare
2f1210b
to
fc97025
Compare
Pull Request Test Coverage Report for Build nicola.cabiddu_1845Details
💛 - Coveralls |
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.
Tested in Realm-Kotlin.
@tgoyne is it ok to merge the PR? (it needs a changelog entry probably). |
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.
Needs a changelog entry.
conf.force_sync_history = true; | ||
} | ||
|
||
auto realm = new shared_realm{Realm::get_shared_realm(conf)}; |
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.
No reason to wrap this in a shared_realm
…rieve_persisted_schema_version
8ceef8b
to
45caad4
Compare
What, How & Why?
Kotlin uses some heuristic for which is required to know the local schema version, before opening a synchronized realm via
open_async
.There is no clear API for reading the local schema version without opening the realm, and most importantly, avoiding opening a synchronized realm (in order to guarantee that no sync code is run).
Opening realm in immutable mode seems a viable and simple approach for achieving that, although it will result in a double opening, if a migration is needed (since it requires opening a synchronized realm in async mode).
Another possible approach is to add a new cnf param that the SDK needs to specify and throw an exception inside
RealmCoordinator::do_get_realm
if the new param is set.☑️ ToDos
bindgen/spec.yml
, if public C++ API changed