List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:April 4 2011 9:07pm
Subject:Re: Mysql++ AVOID NULL Columns!! :)
View as plain text  
On 4/3/2011 5:33 AM, Raymond Boettcher wrote:
> should work:
> if(string(vbasketballevent[b]["tf_station_num"]) != mysqlpp::null )

If vbasketballevent is a mysqlpp::Result, there's no reason at all you 
need to convert Result[][] to std::string here.

If it's an STL container of SSQLSes instead, the only reason you might 
have had to do that is that your SSQLS wasn't defined using 
mysqlpp::Null<T> wrappers on the columns that can contain SQL NULL. 
That wasn't possible pre-MySQL++ 3.0, but it is now, so any reason you 
had for doing that once has gone away.

Either way, the check against mysqlpp::null shouldn't need to go through 
any explicit conversions.  MySQL++ fully preserves NULL-ness on values 
now if you use data types that can preserve it.

Getting back to Eric's issue, you are correct, Raymond, that comparing 
to the C NULL constant is wrong, and that part of the fix is to compare 
against MySQL++'s mysqlpp::null value.

> I even use
> mysqlpp::sql_int_unsigned, etc for some of my variables

Are you using mysqlpp::sql_int_unsigned_null, etc., too?  That's 
shorthand for mysqlpp::Null<sql_int_unsigned>, etc.

> trying to compare the information with C++'s int has also given me
> bad compile issues in the past.  I'm not sure if this is still
> true...

Depending on the data types of the columns in use, yes, using the 
lib/sql_types.h typedefs can give better results than using textbook C++ 
types.  That header knows things about the MySQL C API and about the 
platform MySQL++ was built on that aren't expressed in plain old C++ 
data types.
Actually it was this one.Eric Sepich2 Apr
  • Re: Actually it was this one.Jonathan Wakely2 Apr
    • Re: Mysql++ AVOID NULL Columns!! :)Raymond Boettcher3 Apr
      • Re: Mysql++ AVOID NULL Columns!! :)Warren Young4 Apr
        • Re: Mysql++ AVOID NULL Columns!! :)Raymond Boettcher5 Apr
        • Re: Mysql++ AVOID NULL Columns!! :)Jonathan Wakely5 Apr