List:MySQL++« Previous MessageNext Message »
From:Dan Cook (dancook) Date:May 31 2011 10:45pm
Subject:RE: Patch for number of fields from ssqls classes
View as plain text  
> > >>> Trying to use ssqls::field_count in initializer produces errors
> > like
> > >> this
> > >>> ./test/qssqls.cpp:56:1: error: pasting "test" and "::" does not
> > give
> > >> a
> > >>> valid preprocessing token
> > >>
> > >> I haven't looked at the rest of your patch yet, but this is what
I
> > >> meant by my admission that I was obviously on drugs when I
> initially
> > >> discussed this.  You don't want to use the token pasting operator
> > (##)
> > >> here at all.  Just say NAME::field_count.
> > >
> > > Was there a patch committed for this?
> >
> > No, I was waiting for Adrian to take another pass at it, to get rid
> of
> > the last *_NULL stuff.  I believe the fix is trivial.  Maybe you
want
> > to take a shot at it instead?
> 
> Sure I can take a look at it.
> 

Ok so I don't speak pearl, but when I first changed NAME##_NULL to
NAME::field_count everything compiled in the library, but it barfed in
the tests directory with:

	/media1/mysql++-3.1.0/bk-deps g++ -c -o
test_null_comparison_null_comparison.o -Ilib  -I/usr/include/mysql -g
-O2 	./test/null_comparison.cpp
	./test/null_comparison.cpp:33: error: expected `}' before '::'
token
	./test/null_comparison.cpp:33: error: expected initializer
before '}' token
	./test/null_comparison.cpp:33: error: expected declaration
before '}' token
	make: *** [test_null_comparison_null_comparison.o] Error 1


So I tried using NAME##_field_count and that went through just fine
including the examples.

I tested by modifying "ssqls5.cpp" to look like:

       if (res.size() > 0) {
            // Build a select query using the data from the first row
            // returned by our previous query.
            vector<bool> v(stock_field_count, false);
            v[stock_weight] = true;
            v[stock_price] = true;

            query << "select * from stock where " <<
                    res[0].equal_list(" and ", &v);

            // Display the finished query.
            cout << "Custom query:\n" << query << endl;

This worked, but I am not sure this is what's expected.

Oh and BTW the example shows passing a vector<bool> by reference, when
the code actually wants a pointer.  

Dan

Thread
Patch for number of fields from ssqls classesAdrian Cornish22 May
  • Re: Patch for number of fields from ssqls classesWarren Young23 May
    • RE: Patch for number of fields from ssqls classesdancook)31 May
      • Re: Patch for number of fields from ssqls classesWarren Young31 May
        • RE: Patch for number of fields from ssqls classesdancook)31 May
          • RE: Patch for number of fields from ssqls classesdancook)1 Jun