List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:March 17 2008 5:19am
Subject:Re: Problem Handling Null Values
View as plain text  
Sorry, the previous one slipped out early.

Dustin Moore wrote:
> 	mysqlpp::Null<int, mysqlpp::NullisNull> nullIntField = mysqlpp::null;
> 	if (["Unit_id"] != nullIntField) {
> 		// do something with int value
> 	}

1. I don't see the purpose of nullIntField.  You should be able to 
compare any Null<T> to mysqlpp::null directly.

2. There's no need to give NullIsNull as the second argument to Null<T>. 
  It's already the default.

3. Since you're spelling "NullisNull" with a lowercase 'i', either 
you're using MySQL++ 2.x, which doesn't have the SQL null improvements 
in v3, or you haven't read the breakages chapter in the user manual.

4. further argues that this is MySQL++ 2.3 we're talking 
about, so one then wonders why you haven't tried upgrading to v3, which 
allows the much nicer subscripting syntax, even with the zeroth index.

Taken together, the code for v3 should read:

     if (result[0]["Unit_id"] != mysqlpp::null) {
         // do something with int value

Much cleaner, no?
Problem Handling Null ValuesDustin Moore17 Mar
  • Re: Problem Handling Null ValuesWarren Young17 Mar
  • Re: Problem Handling Null ValuesWarren Young17 Mar
    • Re: Problem Handling Null ValuesDustin Moore18 Mar
      • Re: Problem Handling Null ValuesWarren Young18 Mar
        • Re: Problem Handling Null ValuesDustin Moore19 Mar
          • Re: Problem Handling Null ValuesWarren Young19 Mar