[Solved] SQLite: pragma foreign_key_check
I try to execute a QSqlQuery for the following pragma command (sqlite) but it does not return the expected results.
QSqlQuery q("pragma foreign_key_check")
The expected result would be to return the 4 columns table with all foreign key constrains violations. I have entered in purpose some violations but it returns an empty record (q.size() == -1). From sqlite studio I am able to see the results of this commands. no through Qt though.
Other pragma commands like "pragma foreign_key_list(tablename)" work fine.
Can anyone explain why "pragma foreign_key_check" command does not return any result when it should?
Check if the SQLite driver in your Qt is 3.7.16 or higher, because that's the version in which this pragma was introduced. To check version execute query:
Thank you googie!
The problem was exactly that. I had driver version 3.6.19 and now I updated to 220.127.116.11 and the problem solved!
Just for reference the q.size() is again -1 but the violations are returned correctly.
Hi and welcome to devnet,
IIRC, not all database drivers support returning query sizes. You can check with QSqlDriver::hasFeature(QSqlDriver::QuerySize);