List:MySQL++« Previous MessageNext Message »
From:Wolfram Arnold Date:May 11 2005 9:13am
Subject:Patch for const bug in mysql_dt_base::operator std::string ()
View as plain text  
Hi,

The type conversion operator to std::string in mysql_dt_base
(datetime.h) should be declared const.  Otherwise it leads to
compilation bugs with SSQL's that have a field of Date type which is
also comparable, e.g. the following would fail:

sql_create_1(PriceData,
	     1,
	     0,
	     Date, date);

with a compilation error of something like:

g++ -c -g -I. -I/usr/include/mysql -I/usr/src/mysql++-1.7.32/lib
db-update.cpp
db-update.cpp: In function `int sql_compare_PriceData(const PriceData&,
const
   PriceData&) [with mysqlpp::sql_dummy_type dummy = sql_dummy]':
db-update.cpp:108:   instantiated from here
db-update.cpp:402: error: passing `const mysqlpp::Date' as `this'
argument of `
   mysqlpp::mysql_dt_base::operator std::string()' discards qualifiers
db-update.cpp:402: error: passing `const mysqlpp::Date' as `this'
argument of `
   mysqlpp::mysql_dt_base::operator std::string()' discards qualifiers
make: *** [db-update.o] Error 1

Cheers,

Wolfram

Patch (relative to version 1.7.35) follows:

--- datetime.h.old      2005-05-11 00:57:53.000000000 -0700
+++ datetime.h  2005-05-11 01:59:19.000000000 -0700
@@ -21,7 +21,7 @@
 struct mysql_dt_base {
   virtual std::ostream& out_stream(std::ostream&) const = 0;

-  operator std::string ();
+  operator std::string () const;
 };

 /// \if INTERNAL
@@ -160,7 +160,7 @@
        return d.out_stream(s);
 }

-inline mysql_dt_base::operator std::string()
+inline mysql_dt_base::operator std::string() const
 {
   return stream2string<std::string>(*this);
 }


Thread
Patch for const bug in mysql_dt_base::operator std::string ()Wolfram Arnold11 May
  • [Bug?] Missing implementation for value_list(vector<bool>*...)Wolfram Arnold19 May
    • Re: [Bug?] Missing implementation for value_list(vector<bool>*...)Warren Young19 May