Simplify column shifting for removed properties a little

This commit is contained in:
Thomas Goyne 2015-09-04 14:24:11 -07:00
parent a0f1dab71b
commit b7936bb047
1 changed files with 3 additions and 4 deletions

View File

@ -233,16 +233,15 @@ bool ObjectStore::create_tables(Group *group, Schema &target_schema, bool update
// remove extra columns // remove extra columns
size_t deleted = 0; size_t deleted = 0;
for (auto& current_prop : current_schema.properties) { for (auto& current_prop : current_schema.properties) {
current_prop.table_column -= deleted;
auto target_prop = target_object_schema->property_for_name(current_prop.name); auto target_prop = target_object_schema->property_for_name(current_prop.name);
if (!target_prop || property_has_changed(current_prop, *target_prop)) { if (!target_prop || property_has_changed(current_prop, *target_prop)) {
table->remove_column(current_prop.table_column - deleted); table->remove_column(current_prop.table_column);
++deleted; ++deleted;
current_prop.table_column = npos; current_prop.table_column = npos;
changed = true; changed = true;
} }
else {
current_prop.table_column -= deleted;
}
} }
// add missing columns // add missing columns