Hi all!
I have some trouble inserting null using boost::optional inside a
boost::tuple or boost::fusion::vector. It works fine when a value has
been assigned or when not in a tuple, but when an optional inside my
tuple has not been assigned I get an exception: "Column at position 0
contains NULL value and no default was provided".
I have stepped through the code below but I can't figure out why it
is not working, or even if it is supposed to work. Would appreciate
any help figuring this out.
I'm using VC++ 2010 with the SQLite backend.
using namespace soci;
session ses("sqlite3://:memory:");
ses << "CREATE TABLE MYTABLE(FIELD1 DECIMAL(3), FIELD2 DECIMAL(3))";
boost::optional<int> opt1, opt2;
// insertion of null values with boost::optional works
ses << "INSERT INTO MYTABLE(FIELD1, FIELD2) VALUES(:field1, :field2)",
use(opt1), use(opt2);
//typedef boost::fusion::vector< boost::optional<int>, boost::optional<int> >
MyTuple;
typedef boost::tuple< boost::optional<int>, boost::optional<int> > MyTuple;
MyTuple mt1(1, 2), mt2;
// insertion of assigned boost optionals inside tuple works
ses << "INSERT INTO MYTABLE(FIELD1, FIELD2) VALUES(:field1, :field2)", use(mt1);
// insertion of non-assigned boost optionals inside tuple throws exception
ses << "INSERT INTO MYTABLE(FIELD1, FIELD2) VALUES(:field1, :field2)", use(mt2);
Thanks!
Johan
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users