fixed: such field types: no_insertable, no_updatable were not taken into account on Model child objects

added: field type: no_removable - it is used only with child Models objects
This commit is contained in:
Tomasz Sowa 2021-05-21 22:12:10 +02:00
parent fcd2c4775b
commit e0e3465673
3 changed files with 25 additions and 14 deletions

View File

@ -56,10 +56,11 @@ public:
no_insertable = 8,
no_updatable = 16,
no_fetchable = 32, /* not supported yet */
raw_field_name = 64,
dont_use_utf8 = 128,
hexadecimal = 256,
binary = 512,
no_removable = 64,
raw_field_name = 128,
dont_use_utf8 = 256,
hexadecimal = 512,
binary = 1024,
};
/*
@ -122,18 +123,20 @@ public:
return !is_flag_set(no_insertable);
}
bool is_updatable() const
{
return !is_flag_set(no_updatable);
}
bool is_fetchable() const
{
return !is_flag_set(no_fetchable);
}
bool is_removable() const
{
return !is_flag_set(no_removable);
}
bool is_raw_field_name() const
{

View File

@ -1258,26 +1258,34 @@ void Model::field_model_set_parent_key(const wchar_t * db_field_name, Model & fi
}
void Model::field_model_iterate_through_childs(const wchar_t * db_field_name, Model & field_model)
void Model::field_model_iterate_through_childs(const wchar_t * db_field_name, Model & field_model, const FT & field_type)
{
if( model_env->model_work_submode == MORM_MODEL_WORK_SUBMODE_INSERT )
{
field_model.insert_tree(true);
if( field_type.is_insertable() )
field_model.insert_tree(true);
}
if( model_env->model_work_submode == MORM_MODEL_WORK_SUBMODE_UPDATE )
{
field_model.update_tree(true);
if( field_type.is_updatable() )
field_model.update_tree(true);
}
if( model_env->model_work_submode == MORM_MODEL_WORK_SUBMODE_REMOVE )
{
field_model.remove_tree(true);
if( field_type.is_removable() )
field_model.remove_tree(true);
}
if( model_env->model_work_submode == MORM_MODEL_WORK_SUBMODE_SAVE )
{
field_model.save_tree(true);
if( (field_model.save_mode == Model::DO_INSERT_ON_SAVE && field_type.is_insertable()) ||
(field_model.save_mode == Model::DO_UPDATE_ON_SAVE && field_type.is_updatable()) ||
(field_model.save_mode == Model::DO_DELETE_ON_SAVE && field_type.is_removable()) )
{
field_model.save_tree(true);
}
}
}
@ -1483,7 +1491,7 @@ void Model::field_model_for_db(const wchar_t * db_field_name, Model & field_mode
{
if( field_type.is_foreign_key() )
{
field_model_iterate_through_childs(db_field_name, field_model);
field_model_iterate_through_childs(db_field_name, field_model, field_type);
}
}
@ -1491,7 +1499,7 @@ void Model::field_model_for_db(const wchar_t * db_field_name, Model & field_mode
{
if( field_type.is_foreign_key_in_child() )
{
field_model_iterate_through_childs(db_field_name, field_model);
field_model_iterate_through_childs(db_field_name, field_model, field_type);
}
}

View File

@ -643,7 +643,7 @@ protected:
void field_model_save_key(const wchar_t * db_field_name);
void field_model_set_parent_key_in_child(const wchar_t * db_field_name, Model & field_model);
void field_model_set_parent_key(const wchar_t * db_field_name, Model & field_model);
void field_model_iterate_through_childs(const wchar_t * db_field_name, Model & field_model);
void field_model_iterate_through_childs(const wchar_t * db_field_name, Model & field_model, const FT & field_type);
void field_model_generate_flat_string(const wchar_t * flat_field_name, Model & field_model, const FT & field_type);
void field_model_generate_db_sql(const wchar_t * db_field_name, Model & field_model, const FT & field_type);
void field_model_clear_values(Model & field_model);