use MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM instead of MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER when iterating through models containers

This commit is contained in:
Tomasz Sowa 2021-11-08 00:43:01 +01:00
parent f66f5b321c
commit b9990e3b8c
2 changed files with 18 additions and 3 deletions

View File

@ -289,6 +289,13 @@ public:
env.res.type = Ezc::Var<FunInfoStreamType>::Type::TYPE_DATE;
env.res.date = model_env->ezc_var_date;
}
else
if( model_env->model_container_wrapper )
{
env.res.type = Ezc::Var<FunInfoStreamType>::Type::TYPE_MODEL_CONTAINER_WRAPPER;
env.res.model_container_wrapper = model_env->model_container_wrapper;
}
// else
// if( model_env->model )
// {
@ -1214,15 +1221,17 @@ protected:
{
ContainerItemType * item_type_null_pointer = nullptr;
if( model_env->model_work_mode == MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
if( model_env->model_work_mode == MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM )
{
if constexpr (std::is_base_of<Model, ContainerItemType>())
{
if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) &&
(is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) &&
!model_env->wrapper.model_container_wrapper )
!model_env->model_container_wrapper )
{
model_env->wrapper.model_container_wrapper = new ModelWrapperList(&field_value);
model_env->was_field_found = true;
//model_env->wrapper.model_container_wrapper = new ModelWrapperList(&field_value);
model_env->model_container_wrapper = new ModelWrapperList(&field_value);
}
}
}

View File

@ -96,6 +96,7 @@ public:
Model * child_model;
pt::Stream * stream;
bool was_field_found; // used only in MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM
Wrapper wrapper;
@ -104,6 +105,9 @@ public:
const std::type_info * ezc_fun_info_typeinfo;
pt::Space * ezc_var_space_local;
pt::Date * ezc_var_date;
ModelContainerWrapper * model_container_wrapper;
#endif
ModelEnv()
@ -145,6 +149,7 @@ public:
ezc_fun_info_typeinfo = e.ezc_fun_info_typeinfo;
ezc_var_space_local = e.ezc_var_space_local;
ezc_var_date = e.ezc_var_date;
model_container_wrapper = e.model_container_wrapper;
#endif
// schema_name and table_name don't have to be copied
@ -197,6 +202,7 @@ public:
ezc_fun_info_typeinfo = nullptr;
ezc_var_space_local = nullptr;
ezc_var_date = nullptr;
model_container_wrapper = nullptr;
#endif
}