added: to Model: virtual void set_parent_key_in_childs()
for setting a parent key id in child models, it is called after after_insert() method added: SetFieldValueHelper class used for storing primary key values from a parent model git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1204 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -238,7 +238,12 @@ bool Model::insert(ModelData * model_data, bool insert_whole_tree)
|
||||
model_env = &model_env_local;
|
||||
|
||||
model_env->model_data = model_data;
|
||||
return insert_tree(insert_whole_tree);
|
||||
bool status = insert_tree(insert_whole_tree);
|
||||
|
||||
// what about if an exception was thrown? this pointer will not be null
|
||||
model_env = nullptr;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -272,15 +277,19 @@ bool Model::insert_tree(bool insert_whole_tree)
|
||||
{
|
||||
save_mode = DO_UPDATE_ON_SAVE; // IMPROVE ME check if there is a primary key
|
||||
after_insert();
|
||||
set_parent_key_in_childs();
|
||||
}
|
||||
else
|
||||
{
|
||||
after_insert_failure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// what about if an exception was thrown? this pointer will not be null
|
||||
model_env = nullptr;
|
||||
if( insert_whole_tree )
|
||||
{
|
||||
model_env->model_connector_mode = MORM_MODEL_CONNECTOR_MODE_ITERATE_THROUGH_CHILDS_AND_INSERT_XXX;
|
||||
map_fields();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -632,5 +641,30 @@ bool Model::is_empty_field(const wchar_t * value)
|
||||
}
|
||||
|
||||
|
||||
bool Model::is_the_same_field(const wchar_t * field1, const wchar_t * field2)
|
||||
{
|
||||
if( !field1 && !field2 )
|
||||
return true;
|
||||
|
||||
if( !field1 || !field2 )
|
||||
return false;
|
||||
|
||||
bool the_same = false;
|
||||
|
||||
while( *field1 && *field2 )
|
||||
{
|
||||
field1 += 1;
|
||||
field2 += 1;
|
||||
}
|
||||
|
||||
if( *field1 == 0 && *field2 == 0 )
|
||||
{
|
||||
the_same = true;
|
||||
}
|
||||
|
||||
return the_same;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user