Add Realm::get_schema_version()

This commit is contained in:
Thomas Goyne 2015-08-27 11:38:30 -07:00 committed by Ari Lazier
parent 1d25766ebb
commit 7fda90c3b2
2 changed files with 13 additions and 1 deletions

View File

@ -133,7 +133,7 @@ SharedRealm Realm::get_shared_realm(Config config)
}
else if (realm->m_config.read_only) {
if (old_version == ObjectStore::NotVersioned) {
throw UnitializedRealmException("Can't open an un-initizliazed Realm without a Schema");
throw UnitializedRealmException("Can't open an un-initialized Realm without a Schema");
}
ObjectStore::verify_schema(realm->read_group(), *realm->m_config.schema, true);
}
@ -348,6 +348,16 @@ bool Realm::refresh()
return true;
}
uint64_t Realm::get_schema_version(const realm::Realm::Config &config)
{
auto existing_realm = s_global_cache.get_any_realm(config.path);
if (existing_realm) {
return existing_realm->config().schema_version;
}
return ObjectStore::get_schema_version(Realm(config).read_group());
}
SharedRealm RealmCache::get_realm(const std::string &path, std::thread::id thread_id)
{
std::lock_guard<std::mutex> lock(m_mutex);

View File

@ -76,6 +76,8 @@ namespace realm {
// returns if any changes were made
bool update_schema(Schema &schema, uint64_t version);
static uint64_t get_schema_version(Config const& config);
const Config &config() const { return m_config; }
void begin_transaction();