packages feed

sqlite-easy 1.0.0.0 → 1.0.1.0

raw patch · 3 files changed

+19/−18 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Database.Sqlite.Easy: DummyDriver :: DummyDriver
- Database.Sqlite.Easy: class () => Driver d
- Database.Sqlite.Easy: data () => DummyDriver
- Database.Sqlite.Easy: getMigrations :: Driver d => d -> IO [MigrationName]
- Database.Sqlite.Easy: initMigrations :: Driver d => d -> IO ()
- Database.Sqlite.Easy: markDown :: Driver d => MigrationName -> d -> IO ()
- Database.Sqlite.Easy: markUp :: Driver d => MigrationName -> d -> IO ()
- Database.Sqlite.Easy: migrate :: [MigrationName] -> (MigrationName -> SQLite ()) -> (MigrationName -> SQLite ()) -> SQLite ()
- Database.Sqlite.Easy: withTransaction :: Driver d => (d -> IO a) -> d -> IO a
- Database.Sqlite.Easy: data () => ByteString
+ Database.Sqlite.Easy: data ByteString
- Database.Sqlite.Easy: data () => ColumnType
+ Database.Sqlite.Easy: data ColumnType
- Database.Sqlite.Easy: data () => Database
+ Database.Sqlite.Easy: data Database
- Database.Sqlite.Easy: data () => Int64
+ Database.Sqlite.Easy: data Int64
- Database.Sqlite.Easy: data () => MigrationDirection
+ Database.Sqlite.Easy: data MigrationDirection
- Database.Sqlite.Easy: data () => MigrationName
+ Database.Sqlite.Easy: data MigrationName
- Database.Sqlite.Easy: data () => Pool a
+ Database.Sqlite.Easy: data Pool a
- Database.Sqlite.Easy: data () => SQLData
+ Database.Sqlite.Easy: data SQLData
- Database.Sqlite.Easy: data () => SQLError
+ Database.Sqlite.Easy: data SQLError
- Database.Sqlite.Easy: data () => Text
+ Database.Sqlite.Easy: data Text
- Database.Sqlite.Easy: transaction :: forall a. Typeable a => SQLite a -> SQLite a
+ Database.Sqlite.Easy: transaction :: Typeable a => SQLite a -> SQLite a
- Database.Sqlite.Easy.Internal: transaction :: forall a. Typeable a => SQLite a -> SQLite a
+ Database.Sqlite.Easy.Internal: transaction :: Typeable a => SQLite a -> SQLite a

Files

sqlite-easy.cabal view
@@ -1,14 +1,14 @@ cabal-version: 2.4  name: sqlite-easy-version: 1.0.0.0+version: 1.0.1.0 synopsis: A primitive yet easy to use sqlite library. description: A primitive yet easy to use sqlite library built using sqlite-direct, resource-pool and migrant. author: Gil Mizrahi category: Database stability: Experimental maintainer: gil@gilmi.net-copyright: 2022-2023 Gil Mizrahi+copyright: 2022-2024 Gil Mizrahi license: BSD-3-Clause license-file: LICENSE homepage: https://gitlab.com/gilmi/sqlite-easy
src/Database/Sqlite/Easy/Internal.hs view
@@ -8,7 +8,8 @@ -- This module is unstable and may change at any time. module Database.Sqlite.Easy.Internal where -import Database.SQLite3+import Database.SQLite3 (Database, SQLData, Statement)+import qualified Database.SQLite3 as Direct import Data.String (IsString, fromString) import Data.Text (Text) import Data.Typeable@@ -31,15 +32,15 @@ createSqlitePool :: ConnectionString -> IO (Pool Database) createSqlitePool (ConnectionString connStr) =   newPool $ defaultPoolConfig-    (open connStr)-    close+    (Direct.open connStr)+    Direct.close     180     50  -- | Open a database, run some stuff, close the database. withDb :: ConnectionString -> SQLite a -> IO a withDb (ConnectionString connStr) =-  bracket (open connStr) close . flip runSQLite+  bracket (Direct.open connStr) Direct.close . flip runSQLite  -- | Use an active database connection to run some stuff on a database. withDatabase :: Database -> SQLite a -> IO a@@ -63,27 +64,27 @@ run :: SQL -> SQLite [[SQLData]] run (SQL stmt) = do   db <- getDB-  liftIO $ bracket (prepare db stmt) finalize fetchAll+  liftIO $ bracket (Direct.prepare db stmt) Direct.finalize fetchAll  -- | Run a SQL statement with certain parameters on a database and fetch the results. runWith :: SQL -> [SQLData] -> SQLite [[SQLData]] runWith (SQL stmt) params = do   db <- getDB   liftIO $ do-    bracket (prepare db stmt) finalize $ \preparedStmt -> do-      bind preparedStmt params+    bracket (Direct.prepare db stmt) Direct.finalize $ \preparedStmt -> do+      Direct.bind preparedStmt params       fetchAll preparedStmt  -- | Run a statement and fetch all of the data. fetchAll :: Statement -> IO [[SQLData]] fetchAll stmt = do-  res <- step stmt+  res <- Direct.step stmt   case res of-    Row -> do-      row <- columns stmt+    Direct.Row -> do+      row <- Direct.columns stmt       rows <- fetchAll stmt       pure (row : rows)-    Done ->+    Direct.Done ->       pure []  -- * Transaction
src/Database/Sqlite/Easy/Migrant.hs view
@@ -11,7 +11,7 @@ import Database.Migrant.Driver.Class import Database.Migrant.MigrationName import qualified Database.Sqlite.Easy.Internal as Sqlite-import qualified Database.SQLite3 as Sqlite+import qualified Database.SQLite3 as Direct import Control.Monad (void)  -- | Execute a migration against the database.@@ -28,7 +28,7 @@     (\name db -> void . Sqlite.withDatabase db $ migrateDown name)     database -instance Driver Sqlite.Database where+instance Driver Direct.Database where   withTransaction action conn = Sqlite.asTransaction' conn (action conn)    initMigrations conn = do@@ -41,18 +41,18 @@     [] <- Sqlite.withDatabase conn $       Sqlite.runWith         "INSERT INTO _migrations (name) VALUES (?)"-        [Sqlite.SQLText $ unpackMigrationName name]+        [Direct.SQLText $ unpackMigrationName name]     pure ()    markDown name conn = do     [] <- Sqlite.withDatabase conn $       Sqlite.runWith         "DELETE FROM _migrations WHERE name = ?"-        [Sqlite.SQLText $ unpackMigrationName name]+        [Direct.SQLText $ unpackMigrationName name]     pure ()    getMigrations conn = do     result <- Sqlite.withDatabase conn $       Sqlite.run         "SELECT name FROM _migrations ORDER BY id"-    return [ MigrationName name | [Sqlite.SQLText name] <- result ]+    return [ MigrationName name | [Direct.SQLText name] <- result ]