List:MySQL++« Previous MessageNext Message »
From:Michal Date:September 27 2010 12:04pm
Subject:Problem with null string
View as plain text  
Seems that I found bug in mysql++, but as I wrote in previous mail, 
I don't have experience with this library. So I'm not sure.
Ok, the issue is that seems that it is impossible to write 
null param with using SQLQueryParams. You can read the previous 
issue ( which is start point
for this mail. Thanks Diego from e-mail that helps me. The idea
was to use function it_is_null() which is method of
So basically when we use it on String
mysqlpp::String emptyString;
everything seems to be ok.. and now we can check that everything is ok:
if(emptyString.is_null()) {
LOG_DEBUG("Yes it is null :) "); }

and we can see the LOG that it is ok... 
but when I put it to query.str(params);
the null is changing to '' wrrr...

void Query::proc(SQLQueryParms& p)

for (std::vector<SQLParseElement>::iterator i = parse_elems_.begin();
i != parse_elems_.end(); ++i) {
if (param.is_null()) {

From the source code I see that should be ok, because it is the 
same if as I invoke from my code... but it doesn't go there... why?

I've idea because it is not working on the same object, 
when I put it to params it is pushed on vector... it is copied,
so copy constructor is invoked....I make small test:

mysqlpp::String emptyString;
mysqlpp::String emptyString1 = emptyString;
mysqlpp::String emptyString2(emptyString);

and check emptyString1 and emptyString2 is these strings are null

if(emptyString1.is_null()) {
LOG_DEBUG("emptyString1 is null ");}
if(emptyString2is_null()) {
LOG_DEBUG("emptyString2 is null ");}
and seems that there aren't so... seems that copy constructor lost null
information, and because
copy constructor is invoked on 

SQLQueryParms& operator <<(const SQLTypeAdapter& str)
return *this;}

we lost information about null... so it is basically impossible to
 use null param... Or I'm not right... of course maybe I miss 
sth and my e-mail should go to /dev/null ;)
Solution for storing null is use mysqlpp::SQLTypeAdapter(mysqlpp::null)
but I think the problem with copy constructor exists.

Problem with null stringMichal27 Sep
  • Re: Problem with null stringMichal27 Sep
    • Re: Problem with null stringWarren Young27 Sep