rebase fixes

This commit is contained in:
Ari Lazier 2015-07-20 11:53:21 -07:00
parent 2a0a5d234f
commit d8e9d36c88
5 changed files with 16 additions and 11 deletions

View File

@ -188,10 +188,10 @@ std::vector<ObjectStoreException> ObjectStore::validate_object_schema(Group *gro
}
if (current_prop.is_nullable != target_prop->is_nullable) {
if (current_prop.is_nullable) {
validation_errors.push_back("Property '" + current_prop.name + "' is no longer optional.");
exceptions.emplace_back(ObjectStoreException::Kind::ObjectSchemaChangedOptionalProperty, table_schema.name, current_prop, *target_prop);
}
else {
validation_errors.push_back("Property '" + current_prop.name + "' has been made optional.");
exceptions.emplace_back(ObjectStoreException::Kind::ObjectSchemaNewOptionalProperty, table_schema.name, current_prop, *target_prop);
}
}

View File

@ -119,8 +119,10 @@ const ObjectStoreException::FormatStrings ObjectStoreException::s_default_format
"Property '{InfoKeyPrimaryKey}' is no longer a primary key."},
{Kind::ObjectSchemaNewPrimaryKey,
"Property '{InfoKeyPrimaryKey}' has been made a primary key."},
{Kind::ObjectSchemaChangedOptionalProperty,
"Property '{InfoKeyPrimaryKey}' is no longer optional."},
{Kind::ObjectSchemaNewOptionalProperty,
"Property '{InfoKeyPrimaryKey}' has been made optional."},
{Kind::ObjectStoreValidationFailure,
"Migration is required for object type '{InfoKeyObjectType}' due to the following errors: {ValidationErrors}"}
};

View File

@ -38,6 +38,8 @@ namespace realm {
ObjectSchemaMismatchedObjectTypes, // ObjectType, PropertyName, PropertyType, ObjectType, OldObjectType
ObjectSchemaChangedPrimaryKey, // ObjectType, PrimaryKey
ObjectSchemaNewPrimaryKey, // ObjectType, PrimaryKey
ObjectSchemaChangedOptionalProperty,
ObjectSchemaNewOptionalProperty,
ObjectStoreValidationFailure, // ObjectType, vector<ObjectStoreException>
};

View File

@ -41,10 +41,10 @@ Realm::Realm(Config &config) : m_config(config), m_thread_id(this_thread::get_id
m_group = m_read_only_group.get();
}
else {
m_replication = realm::makeWriteLogCollector(config.path, false, config.encryption_key.data());
m_history = realm::make_client_history(config.path, config.encryption_key.data());
SharedGroup::DurabilityLevel durability = config.in_memory ? SharedGroup::durability_MemOnly :
SharedGroup::durability_Full;
m_shared_group = make_unique<SharedGroup>(*m_replication, durability, config.encryption_key.data());
m_shared_group = make_unique<SharedGroup>(*m_history, durability, config.encryption_key.data());
m_group = nullptr;
}
}
@ -167,7 +167,7 @@ void Realm::begin_transaction()
// make sure we have a read transaction
read_group();
LangBindHelper::promote_to_write(*m_shared_group);
LangBindHelper::promote_to_write(*m_shared_group, *m_history);
m_in_transaction = true;
if (announce) {
@ -200,7 +200,7 @@ void Realm::cancel_transaction()
throw RealmException(RealmException::Kind::InvalidTransaction, "Can't cancel a non-existing write transaction");
}
LangBindHelper::rollback_and_continue_as_read(*m_shared_group);
LangBindHelper::rollback_and_continue_as_read(*m_shared_group, *m_history);
m_in_transaction = false;
}
@ -248,7 +248,7 @@ void Realm::notify()
if (m_shared_group->has_changed()) { // Throws
if (m_auto_refresh) {
if (m_group) {
LangBindHelper::advance_read(*m_shared_group);
LangBindHelper::advance_read(*m_shared_group, *m_history);
}
send_local_notifications(DidChangeNotification);
}
@ -284,7 +284,7 @@ bool Realm::refresh()
}
if (m_group) {
LangBindHelper::advance_read(*m_shared_group);
LangBindHelper::advance_read(*m_shared_group, *m_history);
}
else {
// Create the read transaction

View File

@ -33,6 +33,7 @@ namespace realm {
class Realm;
typedef std::shared_ptr<Realm> SharedRealm;
typedef std::weak_ptr<Realm> WeakRealm;
class ClientHistory;
class Realm
{
@ -106,7 +107,7 @@ namespace realm {
typedef std::unique_ptr<std::function<void()>> ExternalNotificationFunction;
void send_external_notifications() { if (m_external_notifier) (*m_external_notifier)(); }
std::unique_ptr<Replication> m_replication;
std::unique_ptr<ClientHistory> m_history;
std::unique_ptr<SharedGroup> m_shared_group;
std::unique_ptr<Group> m_read_only_group;