List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:May 10 2005 8:12pm
Subject:[PATCH] Re: equal_list() using a bool vector
View as plain text  
On Tue, May 10, 2005 at 11:10:31AM -0600, Warren Young wrote:
> Also, can you explain what you found in the library that prevented your 
> example code from working in the first place?  I.e., precisely what 
> problem this patch solves?

From my research, there is a problem in custom.pl, on line 603 (in 1.7.34)
... there is a template member function that has no definition in the
rest of the header.  Specifically:

    template <class Manip>
    NAME##_cus_equal_list<Manip> equal_list(cchar *d, cchar *c, Manip m,
                                            std::vector<bool> *i) const;

Mark found some more.


> >An example of using it....
> >
> >	vector<bool> a(5, false);    
> >	a[stock_weight] = true; 
> >      a[stock_price] = true;    
> >	query << "SELECT * FROM stock WHERE " << q.equal_list(" AND ",
> >&a);  

This example tickles the bug, since equal_list(cchar*, vector<bool>*)
calls the above missing member function.

Below is Mark's patch, diff-ified, plus some warning fixes for out-of-order
constructor arguments (gcc complains about this regularly).  I ran the simple
example which I also included in this patch.  If Mark could retest this,
that would be great.

- Chris


Index: software/mysql++/examples/custom1.cpp
diff -u software/mysql++/examples/custom1.cpp:1.1.1.2
software/mysql++/examples/custom1.cpp:1.2
--- software/mysql++/examples/custom1.cpp:1.1.1.2	Thu Mar  3 23:27:00 2005
+++ software/mysql++/examples/custom1.cpp	Tue May 10 16:08:02 2005
@@ -43,6 +43,17 @@
 		// this is storing the results into a vector of the custom struct
 		// "stock" which was created my the macro above.
 
+		{
+			Query query = con.query();
+			vector<bool> a(5, false);
+			a[stock_weight] = true;
+			a[stock_price] = true;
+			query << "select * from stock where " <<
+				res[0].equal_list(" and ", &a);
+			cout << "Test query:" << endl;
+			cout << query.preview() << endl;
+		}
+
 		cout.setf(ios::left);
 		cout << setw(17) << "Item"
 			<< setw(4) << "Num"
Index: software/mysql++/lib/custom.pl
diff -u software/mysql++/lib/custom.pl:1.7 software/mysql++/lib/custom.pl:1.9
--- software/mysql++/lib/custom.pl:1.7	Mon May  2 06:25:53 2005
+++ software/mysql++/lib/custom.pl	Tue May 10 16:08:02 2005
@@ -376,10 +376,10 @@
   				  const NAME##_cus_value_list<Manip>&); */
   public:
     const NAME *obj;
-    cchar *delem;
-    Manip manip;
     std::vector<bool> *include;
     bool del_vector;
+    cchar *delem;
+    Manip manip;
   public: 
     ~NAME##_cus_value_list () {if (del_vector) delete include;} 
     NAME##_cus_value_list (const NAME *o, cchar *d, Manip m, $cusparms11);
@@ -394,10 +394,10 @@
      				  const NAME##_cus_field_list<Manip>&); */
   public:
     const NAME *obj; 
-    cchar *delem;
-    Manip manip;
     std::vector<bool> *include; 
     bool del_vector; 
+    cchar *delem;
+    Manip manip;
   public: 
     ~NAME##_cus_field_list () {if (del_vector) delete include;} 
     NAME##_cus_field_list (const NAME *o, cchar *d, Manip m, $cusparms11); 
@@ -772,6 +772,24 @@
   } 
 
   template <class Manip>
+  inline NAME##_cus_value_list<Manip> NAME::value_list(cchar *d, Manip m,
+                                                       std::vector<bool> *i) const
{
+    return NAME##_cus_value_list<Manip> (this, d, m, i);
+  }
+
+  template <class Manip>
+  inline NAME##_cus_field_list<Manip> NAME::field_list(cchar *d, Manip m,
+                                                       std::vector<bool> *i) const
{
+    return NAME##_cus_field_list<Manip> (this, d, m, i);
+  }
+
+  template <class Manip>
+  inline NAME##_cus_equal_list<Manip> NAME::equal_list(cchar *d, cchar *c, Manip m,
+                                                       std::vector<bool> *i) const
{
+    return NAME##_cus_equal_list<Manip> (this, d, c, m, i);
+  }
+
+  template <class Manip>
   inline NAME##_cus_value_list<Manip> 
   NAME::value_list(cchar *d, Manip m, sql_cmp_type /*sc*/) const {
     sql_compare_type_def_##CMP (NAME, value, NUM);

Thread
equal_list() using a bool vectorMark Merendino3 May
  • Re: equal_list() using a bool vectorChris Frey4 May
  • Re: equal_list() using a bool vectorWarren Young4 May
RE: equal_list() using a bool vectorMark Merendino5 May
  • Re: equal_list() using a bool vectorWarren Young10 May
    • [PATCH] Re: equal_list() using a bool vectorChris Frey10 May
      • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young10 May
        • Re: [PATCH] Re: equal_list() using a bool vectorChris Frey10 May
          • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young11 May
RE: [PATCH] Re: equal_list() using a bool vectorMark Merendino11 May
  • Re: [PATCH] Re: equal_list() using a bool vectorChris Frey11 May
    • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young11 May