diff --git a/src/ft.h b/src/ft.h index 0344af1..deacf1f 100644 --- a/src/ft.h +++ b/src/ft.h @@ -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 { diff --git a/src/model.cpp b/src/model.cpp index 1739b89..8ba5ab5 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -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); } } diff --git a/src/model.h b/src/model.h index f3f93e3..c7596b9 100644 --- a/src/model.h +++ b/src/model.h @@ -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);