Table creation fails when using namespace for class

Forum for posting problems using QxOrm library

Table creation fails when using namespace for class

Postby max23 » Fri Feb 18, 2011 11:20 am

Hi everyone,

SQLite quits with "unknown database d" when executing the following code:
Code: Select all
QSqlError daoError = qx::dao::create_table<d::Drug>();

As you can see, class "Drug" resides in the namespace "d". QxOrm (or maybe Qt) seems to translate the fully-qualified class name into "d.Drug" as the name for the table to create, resulting in the above error:
Code: Select all
CREATE TABLE d.Drug (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT)

Is there a way to get around this? Thx for any help.
max23
 

Re: Table creation fails when using namespace for class

Postby QxOrm admin » Fri Feb 18, 2011 1:12 pm

Hi,

In your register method of your class drug, you have to specify a table name like this :

Code: Select all
namespace qx {
template <> void register_class(QxClass<d::Drug> & t)
{
   t.setName("drug");
   //...
}}


Note : be careful with 'qx::dao::create_table<>' function : you can use it for tests, but I recommend to design your database with a tool provided by your SGDB.
QxOrm admin
 

Re: Table creation fails when using namespace for class

Postby max23 » Mon Feb 21, 2011 9:24 am

Works like a charm, thanks very much.
max23
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 8 guests

cron