From 08015be2ee52a7e67159b6b0c476bd3e0a2e0b87 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 6 Feb 2024 15:49:11 +0100 Subject: [PATCH] Allow opening with flags + bump version to 0.4.19.0.1 --- Database/SQLite/Simple.hs | 13 +++++++++++++ cabal.project | 6 ++++++ sqlite-simple.cabal | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 cabal.project diff --git a/Database/SQLite/Simple.hs b/Database/SQLite/Simple.hs index 1355cae..6f87211 100644 --- a/Database/SQLite/Simple.hs +++ b/Database/SQLite/Simple.hs @@ -53,13 +53,16 @@ module Database.SQLite.Simple ( , Only(..) , (:.)(..) , Base.SQLData(..) + , Base.SQLOpenFlag(..) , Statement(..) , ColumnIndex(..) , NamedParam(..) -- * Connections , open + , open' , close , withConnection + , withConnection' , setTrace -- * Queries that return results , query @@ -168,6 +171,12 @@ instance Exception FormatError open :: String -> IO Connection open fname = Connection <$> Base.open (T.pack fname) <*> newIORef 0 +-- | Similar to 'open' but allows specifying opening flags. +open' :: String -> [Base.SQLOpenFlag] -> IO Connection +open' fname flags = Connection + <$> Base.open2 (T.pack fname) flags Base.SQLVFSDefault + <*> newIORef 0 + -- | Close a database connection. close :: Connection -> IO () close = Base.close . connectionHandle @@ -177,6 +186,10 @@ close = Base.close . connectionHandle withConnection :: String -> (Connection -> IO a) -> IO a withConnection connString = bracket (open connString) close +-- | Opens a database connection with flags. Similar to 'withConnection'. +withConnection' :: String -> [Base.SQLOpenFlag] -> (Connection -> IO a) -> IO a +withConnection' connString flags = bracket (open' connString flags) close + unUtf8 :: BaseD.Utf8 -> T.Text unUtf8 (BaseD.Utf8 bs) = TE.decodeUtf8 bs diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..7d77412 --- /dev/null +++ b/cabal.project @@ -0,0 +1,6 @@ +packages: . + +source-repository-package + type: git + location: https://github.com/CardanoSolutions/direct-sqlite + tag: 2b14a78cb73805e2e5d84354230e872a223faa39 diff --git a/sqlite-simple.cabal b/sqlite-simple.cabal index a861377..5877469 100644 --- a/sqlite-simple.cabal +++ b/sqlite-simple.cabal @@ -1,5 +1,5 @@ Name: sqlite-simple -Version: 0.4.19.0 +Version: 0.4.19.0.1 Synopsis: Mid-Level SQLite client library Description: Mid-level SQLite client library, based on postgresql-simple. @@ -51,7 +51,7 @@ Library blaze-textual, bytestring >= 0.9, containers, - direct-sqlite >= 2.3.13 && < 2.4, + direct-sqlite == 2.3.29.1, exceptions >= 0.4, template-haskell, text >= 0.11,