Author: wyoung
Date: Wed Mar 11 12:45:30 2009
New Revision: 2483

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2483&view=rev
Log:
- Added is_null() member to SQLTypeAdapter, which just provides access
  to the method of the same name on the underlying SQLBuffer.  There's
  no good reason why this didn't exist before.  SQLString has it...
- Above allows inserting a potentially NULL MySQL++ field from a result
  set back into a template query.  It wasn't working before even though
  SQLString carries the "is null" flag, and it's being copied into
  the STA object for populating the template query because Query::proc()
  wasn't checking the null flag, because STA didn't provide access to
  it.

Modified:
    trunk/lib/query.cpp
    trunk/lib/stadapter.h

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=2483&r1=2482&r2=2483&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Wed Mar 11 12:45:30 2009
@@ -2,7 +2,7 @@
  query.cpp - Implements the Query class.
 
  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
- (c) 2004-2008 by Educational Technology Resources, Inc.  Others may
+ (c) 2004-2009 by Educational Technology Resources, Inc.  Others may
  also hold copyrights on code in this file.  See the CREDITS.txt file
  in the top directory of the distribution for details.
 
@@ -421,12 +421,17 @@
                        }
 
                        SQLTypeAdapter& param = (*c)[num];
-                       SQLTypeAdapter* ss = pprepare(i->option, param, 
c->bound());
-                       MYSQLPP_QUERY_THISPTR << *ss;
-                       if (ss != &param) {
-                               // pprepare() returned a new string object 
instead of
-                               // updating param in place, so we need to 
delete it.
-                               delete ss;
+                       if (param.is_null()) {
+                               MYSQLPP_QUERY_THISPTR << "NULL";
+                       }
+                       else {
+                               SQLTypeAdapter* ss = pprepare(i->option, param, 
c->bound());
+                               MYSQLPP_QUERY_THISPTR << *ss;
+                               if (ss != &param) {
+                                       // pprepare() returned a new string 
object instead of
+                                       // updating param in place, so we need 
to delete it.
+                                       delete ss;
+                               }
                        }
                }
        }

Modified: trunk/lib/stadapter.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/stadapter.h?rev=2483&r1=2482&r2=2483&view=diff
==============================================================================
--- trunk/lib/stadapter.h (original)
+++ trunk/lib/stadapter.h Wed Mar 11 12:45:30 2009
@@ -257,6 +257,14 @@
        /// that must be escaped when used in a SQL query
        bool escape_q() const;
 
+       /// \brief Return true if buffer's contents represent a SQL
+       /// null.
+       ///
+       /// The buffer's actual content will probably be "NULL" or
+       /// something like it, but in the SQL data type system, a SQL
+       /// null is distinct from a plain string with value "NULL".
+       bool is_null() const { return buffer_->is_null(); }
+
        /// \brief Returns true if the internal 'processed' flag is set.
        ///
        /// This is an implementation detail of template queries, used to


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to