Skip to content

Commit 7579cbb

Browse files
committed
Special-case SQLite connections so we turn on PRAGMA foreign_keys.
1 parent 7c3fc3a commit 7579cbb

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Rezoom.SQL.Mapping/ConnectionProvider.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ type DefaultConnectionProvider() =
2525
let conn = provider.CreateConnection()
2626
conn.ConnectionString <- connectionString.ConnectionString
2727
conn.Open()
28+
if conn.GetType().Name = "SQLiteConnection" then
29+
// Encourage SQLite to put the R in RDBMS
30+
use cmd = conn.CreateCommand()
31+
cmd.CommandText <- "PRAGMA foreign_keys=ON;"
32+
cmd.ExecuteNonQuery() |> ignore
2833
conn
2934
override __.Open(name) = DefaultConnectionProvider.Open(name)
3035

0 commit comments

Comments
 (0)