This code is enabling foreign key support. The problem is that this enabling needs to be done on every connection, not just once. Instead of calling with_connection, you should use the setup_connection callback provided on DB::Database.
To verify that the bug exists, you'd have to do multiple sql statements that rely on foreign key constraints to work with different database connections.
https://github.com/imdrasil/jennifer_sqlite3_adapter/blob/767093168fd98881f065226ace2ebb3cff2087ec/src/jennifer_sqlite3_adapter.cr#L51-L57
This code is enabling foreign key support. The problem is that this enabling needs to be done on every connection, not just once. Instead of calling
with_connection
, you should use thesetup_connection
callback provided onDB::Database
.To verify that the bug exists, you'd have to do multiple sql statements that rely on foreign key constraints to work with different database connections.
SQLite docs on enabling foreign key support (The 3rd paragraph in that section states that it needs to happen on every connection): https://www.sqlite.org/foreignkeys.html#fk_enable