Dear community,

I am using soci as an ORM library in my research project with SQLite 
backend.
I have a class for which I wrote the necessary type_conversion to load 
from and store to the database.

My class has std::pair members, for which I use the following way to 
convert:

     static void from_base(values const & v, indicator & ind/* ind */,
             foo & bar {
         pair<char, unsigned int> temp;

         temp.first = v.get<int>("PAIR1");
         temp.second = v.get<int>("PAIR2");
         bar.setPair(temp);
}

And the to_base is similar:

     static void to_base(const foo & bar, values & v,
             indicator & ind) {
         v.set<int>("PAIR1", line.getPair().first);
         v.set<int>("PAIR2", line.getPair().second);

}

When I try to insert to the database, the first element of the pair is 
inserted, but the second element becomes zero.
What happens? Actually when inserting happens, after each v.set(...) 
call the from_base is called.
I put the first element of the pair into the database, then from_base 
reads it back from values, and (because values does not yet contain the 
PAIR2 value) sets the second value to zero.
Then with the call of v.set("PAIR2",...) it sets the value in the 
database to zero (or the default value).

Should this happen? Is this a bug or it is mentioned somewhere in the 
documentation?

Also, why should to_base call from_base after every call of values::set? 
It seems to be a great performance hit for me.



-- 
Regards,
Wacha Gábor
Budapest University of Technology and Economics
Department of Measurement and Information Systems


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to