Chris,
Thanks for the quick reply.
It is not required as a table name (just convenient at moment and setting
manually works fine for me until I find a better name for my table)
Just wondering if the macro could quote the table names as part of its job.
Adrian
2009/6/8 Chris Morgan <christopher.j.morgan@stripped>
> Hi Adrian,
>
> It's usually a bad idea to use SQL reserved words as table/column names.
> Is it absolutely required that your schema use that table name?
>
> MySQL 5.1 reserved word list:
> http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
>
> hth,
>
> -Chris
>
> On Mon, Jun 8, 2009 at 12:04 PM, Adrian Cornish <mysql@stripped>wrote:
>
>> Hi All,
>>
>> I am just trying out mysql++ for the first time (fantastic bit of code)
>> and
>> I think I have discovered a small bug.
>>
>> When creating tables with the ssql macro sql_create - It isnt quoting the
>> table name Option as mysql expect its to be.
>>
>> Versions:
>> mysql++: mysql++-3.0.9
>> mysql: 5.1.34-log
>> gcc: version 4.4.0 (GCC)
>> kernel: 2.6.29.2
>>
>> Table def:
>> CREATE TABLE `Option` (
>> `PKey` int(11) NOT NULL,
>> PRIMARY KEY (`PKey`)
>> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>>
>> Code:
>> <plusplus@stripped>#include <mysql++.h>
>>
>> #include <ssqls.h>
>> #include <iostream>
>>
>> sql_create_1(Option, 1, 0, mysqlpp::sql_int, PKey)
>>
>> int main(int argc, char *argv[])
>> {
>>
>> if(argc>1)
>> Option::table("`Option`");
>>
>> try
>> {
>> mysqlpp::Connection conn("test", "localhost", "adrianc");
>>
>> Option opt(23);
>> mysqlpp::Query query=conn.query();
>> query.insert(opt);
>> query.exec();
>> }
>> catch(const std::exception &e)
>> {
>> std::cout << "EXCEPTION: " << e.what() << '\n';
>> }
>>
>> return 0;
>> }
>>
>> Results
>> dluadrianc:/home/adrianc/tmp> g++ bug.cc -I/usr/local/include/mysql
>> -I/usr/local/include/mysql++ -L/usr/local/lib -lmysqlpp
>> dluadrianc:/home/adrianc/tmp> a.out
>> EXCEPTION: You have an error in your SQL syntax; check the manual that
>> corresponds to your MySQL server version for the right syntax to use near
>> 'Option (PKey) VALUES (23)' at line 1
>> dluadrianc:/home/adrianc/tmp> a.out 1
>> dluadrianc:/home/adrianc/tmp>
>>
>>
>>
>> Adrian Cornish
>>
>
>