fixed: a parent key was not properly set to simple childs (insert statements)
fixed: a parent key was not set in list of childs (insert statements) git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1215 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -52,14 +52,14 @@ public:
|
||||
void make()
|
||||
{
|
||||
person.set_connector(model_connector);
|
||||
//load_defaults(person);
|
||||
load_defaults(person);
|
||||
|
||||
//std::wstring sss = L"cosik";
|
||||
//person.set_field_value_generic(L"email", L"email", sss);
|
||||
std::wstring sss = L"cosik wstawiony dynamicznie";
|
||||
person.set_field_value_generic(L"email", L"email", sss);
|
||||
|
||||
//person.insert();
|
||||
//person.update();
|
||||
//person.save();
|
||||
person.save();
|
||||
//person.remove();
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ void make()
|
||||
|
||||
//std::list<Person> plist = finder.use_table_prefix(false).select().where().eq(L"id", 120).get_list();
|
||||
|
||||
Person p = finder.use_table_prefix(false).select().where().eq(L"id", 120).get();
|
||||
//Person p = finder.use_table_prefix(false).select().where().eq(L"id", 120).get();
|
||||
|
||||
// Person p = finder.prepare_to_select().use_table_prefix(true).raw("select person.id as \"person.id\", person.first_name as \"person.first_name\", person.last_name as \"person.last_name\", person.email as \"person.email\", "
|
||||
// "language.id as \"language.id\", language.english_name as \"language.english_name\", language.local_name as \"language.local_name\", language.code_str as \"language.code_str\", language.code_int as \"language.code_int\", "
|
||||
@@ -80,13 +80,13 @@ void make()
|
||||
// "where person.id=120").get();
|
||||
|
||||
std::cout << "--------------------------------" << std::endl;
|
||||
p.remove();
|
||||
std::cout << "--------------------------------" << std::endl;
|
||||
//p.remove();
|
||||
//std::cout << "--------------------------------" << std::endl;
|
||||
|
||||
std::string str;
|
||||
//str += "--------\n";
|
||||
|
||||
p.to_text(str, true, true);
|
||||
person.to_text(str, true, true);
|
||||
|
||||
// for(Person & person : plist)
|
||||
// {
|
||||
@@ -108,14 +108,14 @@ private:
|
||||
|
||||
static void load_defaults(Person & person)
|
||||
{
|
||||
person.id = 60;
|
||||
person.id = 0;
|
||||
person.first_name = L"MyFirstName";
|
||||
person.last_name = L"MyLastName";
|
||||
person.email = L"myemail@mydomain.ltd";
|
||||
person.set_save_mode(Model::DO_INSERT_ON_SAVE);
|
||||
//person.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
|
||||
person.language.id = 85;
|
||||
person.language.id = 0;
|
||||
person.language.english_name = L"english";
|
||||
person.language.local_name = L"polish";
|
||||
person.language.code_str = L"en";
|
||||
@@ -125,23 +125,73 @@ private:
|
||||
|
||||
std::time_t t = std::time(0);
|
||||
|
||||
person.attachment.id = 40;
|
||||
person.attachment.person_id = 60;
|
||||
// person.attachment.id = 40;
|
||||
person.attachment.person_id = person.id;
|
||||
person.attachment.created_date.FromTime(t);
|
||||
person.attachment.name = L"attachment name";
|
||||
person.attachment.content = "long binary content";
|
||||
person.attachment.some_flags = true;
|
||||
person.attachment.set_save_mode(Model::DO_INSERT_ON_SAVE);
|
||||
//person.attachment.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
|
||||
// //person.attachment.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
//
|
||||
person.attachment.language.id = 86;
|
||||
person.attachment.language.english_name = L"attachment language";
|
||||
person.attachment.language.local_name = L"attachment local name";
|
||||
person.attachment.language.code_str = L"loen";
|
||||
person.attachment.language.code_int = 300;
|
||||
person.attachment.language.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
// person.attachment.language.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
|
||||
Type type;
|
||||
type.id = 0;
|
||||
|
||||
Attachment attachment;
|
||||
attachment.id = 0;
|
||||
attachment.person_id = person.id;
|
||||
attachment.created_date.FromTime(t);
|
||||
attachment.name = L"list attachment 1";
|
||||
attachment.content = "list attachment content";
|
||||
attachment.some_flags = true;
|
||||
attachment.set_save_mode(Model::DO_INSERT_ON_SAVE);
|
||||
//attachment.set_save_mode(Model::DO_UPDATE_ON_SAVE);
|
||||
|
||||
attachment.language.english_name = L"Language dla attachment 1";
|
||||
person.attachments.push_back(attachment);
|
||||
|
||||
type.name = L"Typ dla attachment 1 - 1";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
type.name = L"Typ dla attachment 1 - 2";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
attachment.name = L"list attachment 2";
|
||||
attachment.language.english_name = L"Language dla attachment 2";
|
||||
person.attachments.push_back(attachment);
|
||||
|
||||
type.name = L"Typ dla attachment 2 - 1";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
type.name = L"Typ dla attachment 2 - 2";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
attachment.name = L"list attachment 3";
|
||||
attachment.language.english_name = L"Language dla attachment 3";
|
||||
person.attachments.push_back(attachment);
|
||||
|
||||
type.name = L"Typ dla attachment 3 - 1";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
type.name = L"Typ dla attachment 3 - 2";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
type.name = L"Typ dla attachment 3 - 3";
|
||||
person.attachments.back().types.push_back(type);
|
||||
|
||||
|
||||
//type.name = L"Typik";
|
||||
//person.attachment.types.push_back(type);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user