mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
object store pr feedback
This commit is contained in:
parent
4d24b29550
commit
ecf1924a51
@ -249,8 +249,8 @@ inline typename T::Function RealmClass<T>::create_constructor(ContextType ctx) {
|
||||
}
|
||||
|
||||
static inline void convert_outdated_datetime_columns(const SharedRealm &realm) {
|
||||
if (realm->config().upgrade_initial_version != realm->config().upgrade_final_version &&
|
||||
realm->config().upgrade_initial_version < 5) {
|
||||
int old_file_format_version = realm->file_format_upgraded_from_version();
|
||||
if (old_file_format_version && old_file_format_version < 5) {
|
||||
// any versions earlier than file format 5 are stored as milliseconds and need to be converted to the new format
|
||||
for (auto& object_schema : *realm->config().schema) {
|
||||
auto table = ObjectStore::table_for_object_type(realm->read_group(), object_schema.name);
|
||||
|
@ -105,7 +105,7 @@ std::shared_ptr<Realm> RealmCoordinator::get_realm(Realm::Config config)
|
||||
|
||||
auto realm = std::make_shared<Realm>(std::move(config));
|
||||
realm->init(shared_from_this());
|
||||
|
||||
|
||||
if (!config.read_only && !m_notifier && config.automatic_change_notifications) {
|
||||
try {
|
||||
m_notifier = std::make_unique<ExternalCommitHelper>(*this);
|
||||
|
@ -158,11 +158,6 @@ namespace realm {
|
||||
std::vector<ObjectSchemaValidationException> m_validation_errors;
|
||||
};
|
||||
|
||||
class SchemaUpdateValidationException : public SchemaValidationException {
|
||||
public:
|
||||
SchemaUpdateValidationException(std::vector<ObjectSchemaValidationException> const& errors);
|
||||
};
|
||||
|
||||
class SchemaMismatchException : public ObjectStoreException {
|
||||
public:
|
||||
SchemaMismatchException(std::vector<ObjectSchemaValidationException> const& errors);
|
||||
|
@ -61,7 +61,7 @@ Realm::Config& Realm::Config::operator=(realm::Realm::Config const& c)
|
||||
Realm::Realm(Config config)
|
||||
: m_config(std::move(config))
|
||||
{
|
||||
open_with_config(m_config, m_history, m_shared_group, m_read_only_group);
|
||||
open_with_config(m_config, m_history, m_shared_group, m_read_only_group, this);
|
||||
|
||||
if (m_read_only_group) {
|
||||
m_group = m_read_only_group.get();
|
||||
@ -71,7 +71,8 @@ Realm::Realm(Config config)
|
||||
void Realm::open_with_config(Config& config,
|
||||
std::unique_ptr<Replication>& history,
|
||||
std::unique_ptr<SharedGroup>& shared_group,
|
||||
std::unique_ptr<Group>& read_only_group)
|
||||
std::unique_ptr<Group>& read_only_group,
|
||||
Realm *realm)
|
||||
{
|
||||
try {
|
||||
if (config.read_only) {
|
||||
@ -85,8 +86,10 @@ void Realm::open_with_config(Config& config,
|
||||
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly : SharedGroup::durability_Full;
|
||||
shared_group = std::make_unique<SharedGroup>(*history, durability, config.encryption_key.data(), !config.disable_format_upgrade,
|
||||
[&](int from_version, int to_version) {
|
||||
config.upgrade_initial_version = from_version;
|
||||
config.upgrade_final_version = to_version;
|
||||
if (realm) {
|
||||
realm->upgrade_initial_version = from_version;
|
||||
realm->upgrade_final_version = to_version;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -459,3 +462,11 @@ void Realm::close()
|
||||
m_binding_context = nullptr;
|
||||
m_coordinator = nullptr;
|
||||
}
|
||||
|
||||
int Realm::file_format_upgraded_from_version() const
|
||||
{
|
||||
if (upgrade_initial_version != upgrade_final_version) {
|
||||
return upgrade_initial_version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,9 +79,6 @@ namespace realm {
|
||||
// everything can be done deterministically on one thread, and
|
||||
// speeds up tests that don't need notifications.
|
||||
bool automatic_change_notifications = true;
|
||||
// File format versions populated when a file format upgrade takes place
|
||||
// during realm opening
|
||||
int upgrade_initial_version = 0, upgrade_final_version = 0;
|
||||
|
||||
Config();
|
||||
Config(Config&&);
|
||||
@ -135,6 +132,9 @@ namespace realm {
|
||||
// Realm after closing it will produce undefined behavior.
|
||||
void close();
|
||||
|
||||
// returns the file format version upgraded from, or 0 if not upgraded
|
||||
int file_format_upgraded_from_version() const;
|
||||
|
||||
~Realm();
|
||||
|
||||
void init(std::shared_ptr<_impl::RealmCoordinator> coordinator);
|
||||
@ -161,7 +161,8 @@ namespace realm {
|
||||
static void open_with_config(Config& config,
|
||||
std::unique_ptr<Replication>& history,
|
||||
std::unique_ptr<SharedGroup>& shared_group,
|
||||
std::unique_ptr<Group>& read_only_group);
|
||||
std::unique_ptr<Group>& read_only_group,
|
||||
Realm *realm = nullptr);
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
@ -176,6 +177,9 @@ namespace realm {
|
||||
|
||||
std::shared_ptr<_impl::RealmCoordinator> m_coordinator;
|
||||
|
||||
// File format versions populated when a file format upgrade takes place during realm opening
|
||||
int upgrade_initial_version = 0, upgrade_final_version = 0;
|
||||
|
||||
public:
|
||||
std::unique_ptr<BindingContext> m_binding_context;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user