diff --git a/persistent-sqlite/ChangeLog.md b/persistent-sqlite/ChangeLog.md index feb1edf49..6eaf254b4 100644 --- a/persistent-sqlite/ChangeLog.md +++ b/persistent-sqlite/ChangeLog.md @@ -1,6 +1,11 @@ # Changelog for persistent-sqlite -## 2.13.2 +## 2.13.3.0 + +* [#1486](https://github.com/yesodweb/persistent/pull/1486) + * Add Database.Sqlite.open' which takes a ByteString + +## 2.13.2.0 * [#1488](https://github.com/yesodweb/persistent/pull/1488) * Add `openRawSqliteConn` for creating `RawSqlite SqlBackend` connections diff --git a/persistent-sqlite/Database/Sqlite.hs b/persistent-sqlite/Database/Sqlite.hs index 65a335755..a6a978284 100644 --- a/persistent-sqlite/Database/Sqlite.hs +++ b/persistent-sqlite/Database/Sqlite.hs @@ -52,6 +52,7 @@ module Database.Sqlite ( -- > $ ([PersistInt64 1,PersistInt64 1],[PersistInt64 2,PersistInt64 2]) open, + open', close, prepare, step, @@ -221,10 +222,10 @@ sqlError maybeConnection functionName error = do foreign import ccall "sqlite3_open_v2" openC :: CString -> Ptr (Ptr ()) -> Int -> CString -> IO Int -openError :: Text -> IO (Either Connection Error) +openError :: BS.ByteString -> IO (Either Connection Error) openError path' = do let flag = sqliteFlagReadWrite .|. sqliteFlagCreate .|. sqliteFlagUri - BS.useAsCString (encodeUtf8 path') $ \path -> alloca $ \database -> do + BS.useAsCString path' $ \path -> alloca $ \database -> do err <- decodeError <$> openC path database flag nullPtr case err of ErrorOK -> do database' <- peek database @@ -238,7 +239,11 @@ openError path' = do sqliteFlagUri = 0x40 open :: Text -> IO Connection -open path = do +open path = open' (encodeUtf8 path) + +-- @since 2.13.2.0 +open' :: BS.ByteString -> IO Connection +open' path = do databaseOrError <- openError path case databaseOrError of Left database -> return database