On Mon, Apr 16, 2007 at 07:16:30PM -0600, Warren Young wrote:
> >+SQLString::SQLString(const SQLNullStringTag& value) :
> I think you can get the behavior you want by adding a conversion ctor
> to SQLString that takes a mysqlpp::null_type.
> Is that not sufficient?
It is:
Index: lib/sql_string.h
===================================================================
--- lib/sql_string.h (revision 1526)
+++ lib/sql_string.h (working copy)
@@ -35,6 +35,7 @@
#define MYSQLPP_SQL_STRING_H
#include "common.h"
+#include "null.h"
#include <stdio.h>
#include <string>
@@ -117,6 +118,9 @@
/// value
SQLString(double i);
+ /// \brief Create object representing NULL
+ SQLString(const null_type& i);
+
/// \brief Copy a C string into this object
SQLString& operator =(const char* str)
{
Index: lib/sql_string.cpp
===================================================================
--- lib/sql_string.cpp (revision 1526)
+++ lib/sql_string.cpp (working copy)
@@ -166,5 +166,13 @@
assign(outs.str());
}
+SQLString::SQLString(const null_type& i) :
+string("NULL"),
+is_string(false),
+dont_escape(false),
+processed(false)
+{
+}
+
} // end namespace mysqlpp
Index: examples/tquery.cpp
===================================================================
--- examples/tquery.cpp (revision 1526)
+++ examples/tquery.cpp (working copy)
@@ -44,9 +44,15 @@
// Build a template query to retrieve a stock item given by
// item name.
mysqlpp::Query query = con.query();
- query << "select * from stock where item = %0q";
+ query << "select * from stock where item = %0q:item";
query.parse();
+ query.def["item"] = mysqlpp::null;
+ std::cout << query.str() << std::endl;
+
+ query.def["item"] = mysqlpp::SQLString("foo");
+ std::cout << query.str() << std::endl;
+
// Retrieve an item added by resetdb; it won't be there if
// tquery or custom3 is run since resetdb.
mysqlpp::Result res1 = query.store("Nürnberger Brats");
Greets,
Michael
--
Gentoo Linux developer, http://hansmi.ch/, http://forkbomb.ch/
Attachment: [application/pgp-signature]