Hi,
Your code is correct if you want to change the SQL type for a
specific column mapped to a C++ property.
If you want to change it
more globally, you must use the following collection :
- Code: Select all
QHash<QString, QString> * lstSqlType = qx::QxClassX::getAllSqlTypeByClassName();
This collection associates all SQL types by class name :
http://www.qxorm.com/doxygen/html/class ... ass_x.htmlSo you can write something like this in your code to associate
VARCHAR type to all C++ strings :
- Code: Select all
lstSqlType->insert("QString", "VARCHAR(255)");
lstSqlType->insert("std::string", "VARCHAR(255)");
// etc...
This will overwrite the default settings provided by QxOrm library and you don't have to write "
p->setSqlType("VARCHAR(255)");" in your register function.
There is a thread in the french forum about it, so if you understand a little bit french, you can read here :
http://www.developpez.net/forums/d11377 ... ype-quuid/PS : if you read some other threads in this forum, you will see that I don't recommend to use
qx::create_table<T>() function (I recommend to design the database with a tool provided by your SGBD).
qx::create_table<T>() must be used only for prototypes or samples.
All other queries (
SELECT, INSERT, UPDATE, DELETE) will work correctly with Oracle database...
QxOrm library doesn't create for you your SQL schema : you have to create it => if you want a sample, you can see the method "
qx::QxClassX::dumpSqlSchema()" in the file "
./src/QxRegister/QxClassX.cpp".
I will create a new
Question&Response in the FAQ to explain how it works with another sample to PostgreSQL database.
Moreover, this is a good training to understand introspection engine of QxOrm library
PS2 : a new version (QxOrm 1.2.1) will be released in few days with this new entry to the FAQ : "
How to build your own SQL schema (create and update tables) based on C++ persistents classes registered into QxOrm context ?"