SQL creation weirdness

Forum for posting problems using QxOrm library

SQL creation weirdness

Postby ArKay » Sun May 29, 2011 6:02 pm

Using QxOrm 1.1.5. What could be happening here?

Code: Select all
Starting /home/arkay/Projects/QxOrmTest/Release/QxOrmTest...
[QxOrm] qx::QxSqlDatabase : create new database connection in thread '140441613350752' with key '{85e829b3-f3ac-4da6-bb9d-a4bc11c35321}'
[QxOrm] execute sql query failed : CREATE TABLE Account)
Unable to execute statement
near ")": syntax error
[QxOrm] execute sql query failed : INSERT INTO Account) VALUES)
Unable to fetch row
No query
/home/arkay/Projects/QxOrmTest/Release/QxOrmTest exited with code 0


I have tried following the "drug" example, but it didn't compile since the macro QX_REGISTER_(HPP|CPP)_MY_TEST_EXE doesn't exist, I used QX_REGISTER_(HPP|CPP) instead.

Code: Select all
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "include/precompiled.h"

class Account {
public:
   enum Role {
      USER,
      ADMIN
   };

   Account(): activated(true), locked(false), role(USER) {

   }

   virtual ~Account() {}

   long id;
   bool activated;
   QString alias;
   QString password;
   QString rememberMe;
   QString comment;
   QDateTime created;
   QString email;
   QString homepage;
   QString lastIp;
   QDateTime lastLogin;
   QString location;
   bool locked;
   Role role;
};

QX_REGISTER_HPP(Account, qx::trait::no_base_class_defined, 1)

#endif // ACCOUNT_H


Code: Select all
#include "account.h"

QX_REGISTER_CPP(Account)

namespace qx {
   template <> void register_class(QxClass<Account> & t) {
      t.id(& Account::id, "id");               // Register 'primary key in your database
      t.data(& Account::activated, "activated");
      t.data(& Account::alias, "alias");
      t.data(& Account::password, "password");
      t.data(& Account::rememberMe, "rememberMe");
      t.data(& Account::comment, "comment");
      t.data(& Account::created, "created");
      t.data(& Account::email, "email");
      t.data(& Account::homepage, "homepage");
      t.data(& Account::lastIp, "lastip");
      t.data(& Account::lastLogin, "lastLogin");
      t.data(& Account::location, "location");
      t.data(& Account::locked, "locked");
      t.data(& Account::role, "role");
   }
}
ArKay
 

Re: SQL creation weirdness

Postby QxOrm admin » Sun May 29, 2011 8:22 pm

Hi,

You have to create your own macro to register your classes.
This is the same mechanism as DLL under windows : QxOrm needs to import or export some classes if you are compiling your project or not.

For more information, see qxBlog tutorial and export.h file :
http://www.qxorm.com/qxorm_en/tutorial.html#tuto_4
QxOrm admin
 

Re: SQL creation weirdness

Postby QxOrm admin » Sun May 29, 2011 8:25 pm

I also recommend to see ./test/ directory of QxOrm package before starting your project.
There is good examples to explain how to work with QxOrm library.
Good luck ;)
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 35 guests