Table creation fails on MySQL; AUTOINCREMENT keyword

Forum for posting problems using QxOrm library

Table creation fails on MySQL; AUTOINCREMENT keyword

Postby raw » Tue Jan 11, 2011 7:12 pm

Table creation fails with QxOrm using MySQL as Database. The reason is that QxOrm uses AUTOINCREMENT as keyword for primary keys, but MySQL expects the keyword AUTO_INCREMENT.

mysql> CREATE TABLE mytable (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, creator TEXT, created DATE);
ERROR 1064 (42000): 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 'AUTOINCREMENT, creator TEXT, created DATE)' at line 1
mysql> CREATE TABLE mytable (id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, creator TEXT, created DATE);
Query OK, 0 rows affected (0.08 sec)

mysql>

tested with mysql 5.1.51 and QxOrm 1.1.3.

many thanks for creating QxOrm, great software!
raw
 

Re: Table creation fails on MySQL; AUTOINCREMENT keyword

Postby QxOrm admin » Wed Jan 12, 2011 10:27 am

Hi,

"qx::dao::create_table<>" has been tested only with SQLite database, so I don't recommend to use it.
You have to design your database with a tool provided by your SGBD (pgAdmin with PostgresSql, Navicat or other with MySql, etc...).

All other queries builded with "qx::dao::..." have to work with MySql database (SELECT, INSERT, UPDATE, DELETE, etc...).

Thank you for testing QxOrm library ;)
QxOrm admin
 

Re: Table creation fails on MySQL; AUTOINCREMENT keyword

Postby raw » Wed Jan 12, 2011 12:16 pm

i tought a mysql specific work-around would be good, changing AUTOINCREMENT to AUTO_INCREMENT for mysql would fix most create table commands.

but yeah, using a external tool to create the tables (or edit the generated create table commands by hand) is possible.
raw
 

Re: Table creation fails on MySQL; AUTOINCREMENT keyword

Postby QxOrm admin » Fri Jan 14, 2011 10:19 am

Ok thanks, this work-around will be done with version 1.1.4...
QxOrm admin
 

Re: Table creation fails on MySQL; AUTOINCREMENT keyword

Postby Gundy » Thu Feb 10, 2011 9:21 am

Hello!

For your information :
Same problem if we use QODBC as QxSqlDatabase driverName.
(indeed, in my environment, the ODBC connection uses MySQL ODBC 3.51 driver)

No problem for me, I don't need to create tables from my code ;)
Gundy
 

Re: Table creation fails on MySQL; AUTOINCREMENT keyword

Postby QxOrm admin » Thu Feb 10, 2011 10:06 am

Thanks for this information :)
I think it is necessary to add something (plugin system ???) to manage all specifics cases with databases.

For CREATE TABLE, it is a minor bug, because I think it is better to design the database with a tool provided by the SGBD.
But for all other QxOrm queries, if you find a specific case for your database, it is a major bug that needs to be corrected (today, I have not found this kind of bug, but I have not tested all databases).
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 13 guests