packages feed

snaplet-persistent 0.4.1 → 0.5

raw patch · 5 files changed

+56/−44 lines, 5 filesdep ~lensdep ~persistentdep ~persistent-postgresql

Dependency ranges changed: lens, persistent, persistent-postgresql, persistent-template, readable, text, time

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@+# 0.5++* Upgrade to persistent 2+* Accept newer versions of other deps++# 0.4.1++* Add initPersistGeneric+ # 0.4  * Update heist dependency to 0.14
snaplet-persistent.cabal view
@@ -1,5 +1,5 @@ name:           snaplet-persistent-version:        0.4.1+version:        0.5 synopsis:       persistent snaplet for the Snap Framework description:    Snaplet support for using the Postgresql database                 with a Snap Framework application via the persistent@@ -42,21 +42,21 @@     clientsession              >= 0.7.2   && < 0.10,     configurator               >= 0.2     && < 0.4,     heist                      >= 0.14    && < 0.15,-    lens                       >= 3.7.6   && < 4.5,+    lens                       >= 3.7.6   && < 4.7,     errors                     >= 1.4     && < 1.5,     MonadCatchIO-transformers  >= 0.3     && < 0.4,     monad-logger               >= 0.2.4   && < 0.4,     mtl                        >= 2       && < 3,-    persistent                 >= 1.2     && < 1.4,-    persistent-postgresql      >= 1.2     && < 1.4,-    persistent-template        >= 1.2     && < 1.4,-    readable                   >= 0.1     && < 0.3,+    persistent                 >= 2.0     && < 2.2,+    persistent-postgresql      >= 2.0     && < 2.2,+    persistent-template        >= 2.0     && < 2.2,+    readable                   >= 0.1     && < 0.4,     resource-pool              >= 0.2     && < 0.3,     resourcet                  >= 0.4     && < 1.2,     safe                       >= 0.3     && < 0.4,     snap                       >= 0.13    && < 0.14,-    text                       >= 0.11    && < 1.2,-    time                       >= 1.1     && < 1.5,+    text                       >= 0.11    && < 1.3,+    time                       >= 1.1     && < 1.6,     transformers               >= 0.2     && < 0.5,     unordered-containers       >= 0.2     && < 0.3 
src/Snap/Snaplet/Auth/Backends/Persistent.hs view
@@ -29,16 +29,16 @@ ------------------------------------------------------------------------------ import           Control.Monad import           Control.Monad.Trans-import qualified Data.HashMap.Strict          as HM+import qualified Data.HashMap.Strict                         as HM import           Data.Maybe-import           Data.Text                    (Text)-import qualified Data.Text                    as T-import qualified Data.Text.Encoding           as T+import           Data.Text                                   (Text)+import qualified Data.Text                                   as T+import qualified Data.Text.Encoding                          as T import           Data.Time import           Database.Persist import           Database.Persist.Postgresql import           Database.Persist.Quasi-import           Database.Persist.TH          hiding (derivePersistField)+import           Database.Persist.TH                         hiding (derivePersistField) import           Heist import           Heist.Compiled import           Paths_snaplet_persistent@@ -47,9 +47,9 @@ import           Snap.Snaplet.Auth import           Snap.Snaplet.Persistent import           Snap.Snaplet.Session-import           Web.ClientSession            (getKey)+import           Web.ClientSession                           (getKey) -------------------------------------------------------------------------------import           Snap.Snaplet.Auth.Backends.Persistent.Types +import           Snap.Snaplet.Auth.Backends.Persistent.Types   ------------------------------------------------------------------------------@@ -63,7 +63,7 @@ -- > share [mkMigrate "migrateAll"] $ -- >    authEntityDefs ++ -- >    $(persistFileWith lowerCaseSettings "schema.txt")-authEntityDefs :: [EntityDef SqlType]+authEntityDefs :: [EntityDef] authEntityDefs = $(persistFileWith lowerCaseSettings "schema.txt")  @@ -77,8 +77,8 @@ -- | Function to convert a 'SnapAuthUser' entity into the auth snaplet's -- 'AuthUser'. db2au :: Entity SnapAuthUser -> AuthUser-db2au (Entity (Key k) SnapAuthUser{..}) = AuthUser-  { userId               = Just . UserId . fromPersistValue' $ k+db2au (Entity k SnapAuthUser{..}) = AuthUser+  { userId               = Just . UserId $ showKey k   , userLogin            = snapAuthUserLogin   , userEmail            = Just snapAuthUserEmail   , userPassword         = Just . Encrypted . T.encodeUtf8
src/Snap/Snaplet/Auth/Backends/Persistent/Types.hs view
@@ -1,19 +1,21 @@-{-# LANGUAGE EmptyDataDecls    #-}-{-# LANGUAGE FlexibleContexts  #-}-{-# LANGUAGE GADTs             #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards   #-}-{-# LANGUAGE TemplateHaskell   #-}-{-# LANGUAGE TypeFamilies      #-}+{-# LANGUAGE EmptyDataDecls             #-}+{-# LANGUAGE FlexibleContexts           #-}+{-# LANGUAGE GADTs                      #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses      #-}+{-# LANGUAGE OverloadedStrings          #-}+{-# LANGUAGE RecordWildCards            #-}+{-# LANGUAGE TemplateHaskell            #-}+{-# LANGUAGE TypeFamilies               #-}   module Snap.Snaplet.Auth.Backends.Persistent.Types where  -------------------------------------------------------------------------------import           Data.Text                    (Text)+import           Data.Text              (Text) import           Data.Time import           Database.Persist.Quasi-import           Database.Persist.TH          hiding (derivePersistField)+import           Database.Persist.TH    hiding (derivePersistField) ------------------------------------------------------------------------------  
src/Snap/Snaplet/Persistent.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE FlexibleContexts  #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeFamilies      #-}+{-# LANGUAGE FlexibleContexts      #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings     #-}+{-# LANGUAGE TypeFamilies          #-}  module Snap.Snaplet.Persistent   ( initPersist@@ -100,12 +101,12 @@ -- -- mkPool is a function to construct a pool of connections to your database initPersistGeneric-    :: Initializer b PersistState (Pool Connection)+    :: Initializer b PersistState (Pool SqlBackend)     -> SqlPersistT (NoLoggingT IO) a     -> SnapletInit b PersistState initPersistGeneric mkPool migration = makeSnaplet "persist" description datadir $ do     p <- mkPool-    liftIO . runNoLoggingT $ runSqlPool migration p+    _ <- liftIO $ runNoLoggingT $ runSqlPool migration p     return $ PersistState p   where     description = "Snaplet for persistent DB library"@@ -118,7 +119,7 @@ mkPgPool conf = do   pgConStr <- liftIO $ require conf "postgre-con-str"   cons <- liftIO $ require conf "postgre-pool-size"-  createPostgresqlPool pgConStr cons+  liftIO . runNoLoggingT $ createPostgresqlPool pgConStr cons   -------------------------------------------------------------------------------@@ -150,44 +151,44 @@  ------------------------------------------------------------------------------- -- | Make a Key from an Int.-mkKey :: Int -> Key entity-mkKey = Key . toPersistValue+mkKey :: ToBackendKey SqlBackend entity => Int -> Key entity+mkKey = fromBackendKey . SqlBackendKey . fromIntegral   ------------------------------------------------------------------------------- -- | Makes a Key from a ByteString.  Calls error on failure.-mkKeyBS :: ByteString -> Key entity+mkKeyBS :: ToBackendKey SqlBackend entity => ByteString -> Key entity mkKeyBS = mkKey . fromMaybe (error "Can't ByteString value") . fromBS   ------------------------------------------------------------------------------- -- | Makes a Key from Text.  Calls error on failure.-mkKeyT :: Text -> Key entity+mkKeyT :: ToBackendKey SqlBackend entity => Text -> Key entity mkKeyT = mkKey . fromMaybe (error "Can't Text value") . fromText   ------------------------------------------------------------------------------- -- | Makes a Text representation of a Key.-showKey :: Key e -> Text+showKey :: ToBackendKey SqlBackend e => Key e -> Text showKey = T.pack . show . mkInt   ------------------------------------------------------------------------------- -- | Makes a ByteString representation of a Key.-showKeyBS :: Key e -> ByteString+showKeyBS :: ToBackendKey SqlBackend e => Key e -> ByteString showKeyBS = T.encodeUtf8 . showKey   ------------------------------------------------------------------------------- -- | Converts a Key to Int.  Fails with error if the conversion fails.-mkInt :: Key a -> Int-mkInt = fromPersistValue' . unKey+mkInt :: ToBackendKey SqlBackend a => Key a -> Int+mkInt = fromIntegral . unSqlBackendKey . toBackendKey   ------------------------------------------------------------------------------- -- | Converts a Key to Word64.  Fails with error if the conversion fails.-mkWord64 :: Key a -> Word64-mkWord64 = fromPersistValue' . unKey+mkWord64 :: ToBackendKey SqlBackend a => Key a -> Word64+mkWord64 = fromIntegral . unSqlBackendKey . toBackendKey   -------------------------------------------------------------------------------