added: to Model::to_text() methods added dump_mode (bool) parameter

an additional field (model_save_mode) is printed
changed: if there is no an object the Cursor returns a Model with DO_NOTHING_ON_SAVE flag now
         (DO_INSERT_ON_SAVE was beforehand)
fixed:   when reading a result from db: for auto generated select there should be used
         get_value_by_field_index() method instead of get_value_by_field_name() 
changed: flat string (json) is generated only if a model has DO_INSERT_ON_SAVE
         or DO_UPDATE_ON_SAVE or is dump_mode turn on
         




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1208 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2019-09-13 18:17:02 +00:00
parent c133e949ce
commit 057d879b4c
9 changed files with 81 additions and 31 deletions

View File

@@ -76,10 +76,10 @@ public:
field(L"id", id, false, false, true);
field(L"person_id", person_id);
field(L"name", name);
field(L"language_id", language);
field(L"content", content);
field(L"some_flags", some_flags);
field(L"created_date", created_date);
field(L"language_id", L"language", language);
}

View File

@@ -79,9 +79,9 @@ public:
field(L"first_name", first_name);
field(L"last_name", last_name);
field(L"email", email);
field(L"language_id", language);
field(L"language_id", L"language", language);
field(L"person_id", attachment, true, true, false);
field(L"person_id", L"attachment", attachment, true, true, false);
//field(L"person_id", attachment, f::insertable | f::updatable | f::foreign_key);
//field(L"person_id", attachment, f::insertable, f::updatable, f::foreign_key);
}

View File

@@ -52,16 +52,25 @@ 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";
//person.set_field_value_generic(L"email", L"email", sss);
person.insert();
//person.insert();
//person.update();
//person.save();
//person.remove();
morm::Finder<Person> finder(model_connector);
Person p = finder.select().where().eq(L"id", 110).get();
std::string str;
p.to_text(str, true, true);
std::cout << str << std::endl;
}