fixed: in Finder: we should set model_data to nullptr after fetching an object

model_data points often to a local object (on the stack) so it would be incorrect
       to use it in the future



git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1131 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2018-10-24 16:28:19 +00:00
parent 346fe193f3
commit 011d8f96e8
1 changed files with 18 additions and 7 deletions

View File

@ -475,6 +475,7 @@ public:
// if yes then make sure to call db_connector->clear_last_query_result();
}
result.model_data = nullptr;
db_connector->clear_last_query_result();
}
}
@ -519,14 +520,24 @@ public:
result.emplace_back(); // it returns a reference from c++17
ModelClass & added_model = result.back();
added_model.set_connector(model_connector);
added_model.clear();
added_model.set_save_mode(Model::DO_UPDATE_ON_SAVE); // IMPROVE ME check if there is a primary key
added_model.model_data = model_data;
added_model.before_select();
added_model.map_values_from_query();
added_model.after_select();
try
{
added_model.set_connector(model_connector);
added_model.clear();
added_model.set_save_mode(Model::DO_UPDATE_ON_SAVE); // IMPROVE ME check if there is a primary key
added_model.model_data = model_data;
added_model.before_select();
added_model.map_values_from_query();
added_model.after_select();
}
catch(...)
{
res = false;
// throw or something?
// make sure to call db_connector->clear_last_query_result()
}
added_model.model_data = nullptr;
db_connector->advance_current_row();
}