Fix crash when adding a property to a model without updating the schema version.

This commit is contained in:
JP Simard 2015-08-03 10:11:43 -07:00 committed by Ari Lazier
parent 043f5ff4ab
commit 453e4d8277
1 changed files with 4 additions and 3 deletions

View File

@ -232,11 +232,12 @@ void ObjectStore::update_column_mapping(Group *group, ObjectSchema &target_schem
ObjectSchema table_schema(group, target_schema.name); ObjectSchema table_schema(group, target_schema.name);
for (auto& target_prop : target_schema.properties) { for (auto& target_prop : target_schema.properties) {
auto table_prop = table_schema.property_for_name(target_prop.name); auto table_prop = table_schema.property_for_name(target_prop.name);
REALM_ASSERT_DEBUG(table_prop); if (table_prop) {
// Update target property column to match what's in the realm if it exists
target_prop.table_column = table_prop->table_column; target_prop.table_column = table_prop->table_column;
} }
} }
}
// set references to tables on targetSchema and create/update any missing or out-of-date tables // set references to tables on targetSchema and create/update any missing or out-of-date tables
// if update existing is true, updates existing tables, otherwise validates existing tables // if update existing is true, updates existing tables, otherwise validates existing tables