diff --git a/src/Utils/DB.hs b/src/Utils/DB.hs index de9608a4d..be7ddd292 100644 --- a/src/Utils/DB.hs +++ b/src/Utils/DB.hs @@ -99,7 +99,7 @@ updateGetEntity k = fmap (Entity k) . updateGet k -- | insert or replace a record based on a single uniqueness constraint -- this function was meant to be supplied with the uniqueness constraint, but it would be unsafe if the uniqueness constraint would not match the supplied record -replaceBy :: (PersistUniqueWrite backend, MonadIO m, OnlyOneUniqueKey record, PersistEntityBackend record ~ BaseBackend backend) +replaceBy :: (SafeToInsert record, PersistUniqueWrite backend, MonadIO m, OnlyOneUniqueKey record, PersistEntityBackend record ~ BaseBackend backend) => record -> ReaderT backend m () replaceBy r = do u <- onlyUnique r @@ -158,6 +158,7 @@ checkUniqueKeys (x:xs) = do put :: ( MonadIO m , PersistUniqueWrite backend , PersistRecordBackend record backend + , SafeToInsert record ) => record -> ReaderT backend m (Key record) -- ^ `insert`, but remove all records with matching uniqueness constraints first diff --git a/src/Yesod/Core/Instances.hs b/src/Yesod/Core/Instances.hs index 88f42a5c5..eab7ef562 100644 --- a/src/Yesod/Core/Instances.hs +++ b/src/Yesod/Core/Instances.hs @@ -55,7 +55,7 @@ routeToPathPiece . renderRoute -instance (RenderRoute site, ParseRoute site) => PathPiece (Route site) where +instance ParseRoute site => PathPiece (Route site) where fromPathPiece = routeFromPathPiece toPathPiece = routeToPathPiece @@ -71,7 +71,7 @@ instance ParseRoute site => FromJSONKey (Route site) where instance RenderRoute site => ToJSONKey (Route site) where toJSONKey = toJSONKeyText routeToPathPiece -instance (RenderRoute site, ParseRoute site) => Binary (Route site) where +instance ParseRoute site => Binary (Route site) where put = Binary.put . toPathPiece get = Binary.get >>= maybe (fail "Could not parse route") return . fromPathPiece