oatpp-sqlite icon indicating copy to clipboard operation
oatpp-sqlite copied to clipboard

How to properly enable foreign_keys support

Open nyyakko opened this issue 7 months ago • 1 comments

Anyone cares to shed a light on how to enable foreign_keys with this library? I've tried doing the following:

OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::provider::Provider<oatpp::sqlite::Connection>>, dbConnectionProvider)([] {
    auto connectionProvider = std::make_shared<oatpp::sqlite::ConnectionProvider>("database.sqlite");
    auto result = sqlite3_exec(connectionProvider->get().object.get()->getHandle(), "PRAGMA foreign_keys=ON;", nullptr, nullptr, nullptr);
    assert(result == SQLITE_OK && "ERROR ENABLING foreign_keys");
    return oatpp::sqlite::ConnectionPool::createShared(connectionProvider, 10, std::chrono::seconds(5));
}());

without success. if anyone could help me with this I'd be glad.

nyyakko avatar Jul 15 '24 01:07 nyyakko