Page 1 of 1

Enable FK on SQLite engine

PostPosted: Tue Sep 13, 2016 1:12 pm
by gianks
Hi all,
testing my application i've found inconsistent values sometimes in FK columns, probably after wrong ops my side.

Looking on sqlite website seems that by default is necessary since a certain release to manualy enable the PRAGMA at the startup of the application to enforce the FK (uniqueness is already enforced in any case).
How can i do that through QxOrm when i initialize the singleton instance?

See here: http://www.sqlite.org/pragma.html#pragma_foreign_keys

Thanks
Best Regards
Gianluca

Re: Enable FK on SQLite engine

PostPosted: Tue Sep 13, 2016 1:44 pm
by qxorm
Hello,

You can use the qx::dao::call_query() function to execute a custom SQL query : https://www.qxorm.com/qxorm_en/manual.html#manual_3610

For example :
Code: Select all
QString sql = "PRAGMA foreign_keys;";
qx_query query(sql);
QSqlError err = qx::dao::call_query(query);