object store pr feedback

This commit is contained in:
Ari Lazier 2016-05-23 11:57:07 -07:00
parent d05542c031
commit ceceeab9a5
4 changed files with 24 additions and 14 deletions

View File

@ -158,11 +158,6 @@ namespace realm {
std::vector<ObjectSchemaValidationException> m_validation_errors; std::vector<ObjectSchemaValidationException> m_validation_errors;
}; };
class SchemaUpdateValidationException : public SchemaValidationException {
public:
SchemaUpdateValidationException(std::vector<ObjectSchemaValidationException> const& errors);
};
class SchemaMismatchException : public ObjectStoreException { class SchemaMismatchException : public ObjectStoreException {
public: public:
SchemaMismatchException(std::vector<ObjectSchemaValidationException> const& errors); SchemaMismatchException(std::vector<ObjectSchemaValidationException> const& errors);

View File

@ -61,7 +61,7 @@ Realm::Config& Realm::Config::operator=(realm::Realm::Config const& c)
Realm::Realm(Config config) Realm::Realm(Config config)
: m_config(std::move(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) { if (m_read_only_group) {
m_group = m_read_only_group.get(); m_group = m_read_only_group.get();
@ -71,7 +71,8 @@ Realm::Realm(Config config)
void Realm::open_with_config(Config& config, void Realm::open_with_config(Config& config,
std::unique_ptr<Replication>& history, std::unique_ptr<Replication>& history,
std::unique_ptr<SharedGroup>& shared_group, std::unique_ptr<SharedGroup>& shared_group,
std::unique_ptr<Group>& read_only_group) std::unique_ptr<Group>& read_only_group,
Realm *realm)
{ {
try { try {
if (config.read_only) { 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; 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, shared_group = std::make_unique<SharedGroup>(*history, durability, config.encryption_key.data(), !config.disable_format_upgrade,
[&](int from_version, int to_version) { [&](int from_version, int to_version) {
config.upgrade_initial_version = from_version; if (realm) {
config.upgrade_final_version = to_version; realm->upgrade_initial_version = from_version;
realm->upgrade_final_version = to_version;
}
}); });
} }
} }
@ -459,3 +462,11 @@ void Realm::close()
m_binding_context = nullptr; m_binding_context = nullptr;
m_coordinator = 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;
}

View File

@ -79,9 +79,6 @@ namespace realm {
// everything can be done deterministically on one thread, and // everything can be done deterministically on one thread, and
// speeds up tests that don't need notifications. // speeds up tests that don't need notifications.
bool automatic_change_notifications = true; 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(Config&&); Config(Config&&);
@ -135,6 +132,9 @@ namespace realm {
// Realm after closing it will produce undefined behavior. // Realm after closing it will produce undefined behavior.
void close(); void close();
// returns the file format version upgraded from, or 0 if not upgraded
int file_format_upgraded_from_version() const;
~Realm(); ~Realm();
void init(std::shared_ptr<_impl::RealmCoordinator> coordinator); void init(std::shared_ptr<_impl::RealmCoordinator> coordinator);
@ -161,7 +161,8 @@ namespace realm {
static void open_with_config(Config& config, static void open_with_config(Config& config,
std::unique_ptr<Replication>& history, std::unique_ptr<Replication>& history,
std::unique_ptr<SharedGroup>& shared_group, std::unique_ptr<SharedGroup>& shared_group,
std::unique_ptr<Group>& read_only_group); std::unique_ptr<Group>& read_only_group,
Realm *realm = nullptr);
private: private:
Config m_config; Config m_config;
@ -176,6 +177,9 @@ namespace realm {
std::shared_ptr<_impl::RealmCoordinator> m_coordinator; 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: public:
std::unique_ptr<BindingContext> m_binding_context; std::unique_ptr<BindingContext> m_binding_context;