dynamodb-simple 0.6.0.0 → 0.6.0.1
raw patch · 4 files changed
+22/−17 lines, 4 filesdep ~amazonka-dynamodb
Dependency ranges changed: amazonka-dynamodb
Files
- changelog.md +4/−0
- dynamodb-simple.cabal +3/−3
- src/Database/DynamoDB/Class.hs +4/−4
- src/Database/DynamoDB/Migration.hs +11/−10
changelog.md view
@@ -1,3 +1,7 @@+# 0.6.0.1++- add compatibility with amazonka > 1.6.0+ # 0.6.0.0 - add dDecodeEither method to DynamoEncodable for better error reporting
dynamodb-simple.cabal view
@@ -1,5 +1,5 @@ name: dynamodb-simple-version: 0.6.0.0+version: 0.6.0.1 synopsis: Typesafe library for working with DynamoDB database description: Framework for accessing DynamoDB database. The majority of AWS API is available to the user in a convenient, simple and typesafe manner.@@ -27,7 +27,7 @@ Database.DynamoDB.Internal, Database.DynamoDB.BatchRequest, Database.DynamoDB.QueryRequest, Database.DynamoDB.THLens, Database.DynamoDB.THContains, Database.DynamoDB.THConvert- build-depends: base >=4.9 && <5, amazonka-dynamodb >= 1.5.0, generics-sop,+ build-depends: base >=4.9 && <5, amazonka-dynamodb >= 1.6.0, generics-sop, unordered-containers, text, lens, double-conversion, semigroups, bytestring >= 0.10.8.0, containers, monad-supply, template-haskell, transformers, exceptions,@@ -44,7 +44,7 @@ main-is: Spec.hs other-modules: BaseSpec, NestedSpec build-depends: base, dynamodb-simple, hspec, text, lens, transformers,- safe-exceptions, amazonka-dynamodb >= 1.4.5, amazonka, conduit,+ safe-exceptions, amazonka-dynamodb >= 1.6.0, amazonka, conduit, semigroups, hashable, containers, unordered-containers, tagged default-language: Haskell2010
src/Database/DynamoDB/Class.hs view
@@ -312,9 +312,9 @@ attrdefs = [D.attributeDefinition hashname (dType (Proxy :: Proxy hash))] keyschema = keySchemaElement hashname D.Hash :| [] proj | Just lst <- nonEmpty attrlist =- D.projection & D.pProjectionType .~ Just D.Include+ D.projection & D.pProjectionType .~ Just D.PTInclude & D.pNonKeyAttributes .~ Just lst- | otherwise = D.projection & D.pProjectionType .~ Just D.KeysOnly+ | otherwise = D.projection & D.pProjectionType .~ Just D.PTKeysOnly parentKey = primaryFields (Proxy :: Proxy parent) attrlist = filter (`notElem` (parentKey ++ [hashname])) $ allFieldNames (Proxy :: Proxy a) @@ -331,9 +331,9 @@ keyschema = keySchemaElement hashname D.Hash :| [keySchemaElement rangename D.Range] -- proj | Just lst <- nonEmpty attrlist =- D.projection & D.pProjectionType .~ Just D.Include+ D.projection & D.pProjectionType .~ Just D.PTInclude & D.pNonKeyAttributes .~ Just lst- | otherwise = D.projection & D.pProjectionType .~ Just D.KeysOnly+ | otherwise = D.projection & D.pProjectionType .~ Just D.PTKeysOnly parentKey = primaryFields (Proxy :: Proxy parent) attrlist = filter (`notElem` (parentKey ++ [hashname, rangename])) $ allFieldNames (Proxy :: Proxy a)
src/Database/DynamoDB/Migration.hs view
@@ -1,11 +1,11 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-}-{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE TypeFamilies #-} module Database.DynamoDB.Migration ( runMigration@@ -13,8 +13,9 @@ import Control.Arrow (first) import Control.Concurrent (threadDelay)-import Control.Lens (_1, set, view, (%~), (.~),- (^.), (^..), (^?), _Just)+import Control.Lens (set, view, (%~), (.~),+ (^.), (^..), (^?), _1,+ _Just) import Control.Monad (unless, void, when) import Control.Monad.Catch (throwM) import Control.Monad.IO.Class (liftIO)@@ -25,7 +26,7 @@ import Data.Function ((&)) import qualified Data.HashMap.Strict as HMap import Data.List (nub, (\\))-import Data.Maybe (mapMaybe, fromMaybe)+import Data.Maybe (fromMaybe, mapMaybe) import Data.Monoid ((<>)) import Data.Proxy import qualified Data.Set as Set@@ -60,8 +61,8 @@ descr <- getTableDescription name status <- maybe (throwM (DynamoException "Missing table status")) return (descr ^. D.tdTableStatus) let idxstatus = descr ^.. D.tdGlobalSecondaryIndexes . traverse . D.gsidIndexStatus . _Just- if | checkindex -> return (status /= D.Active || any (/= D.ISActive) idxstatus)- | otherwise -> return (status /= D.Active)+ if | checkindex -> return (status /= D.TSActive || any (/= D.ISActive) idxstatus)+ | otherwise -> return (status /= D.TSActive) -- | Delete specified indices from the database deleteIndices :: forall m. MonadAWS m => T.Text -> [T.Text] -> m ()@@ -96,7 +97,7 @@ -- Assume the indices were created by this module and we want them exactly the same projectionOk newidx oldidx = -- Allow the index to have more fields than we know about- newprojtype == Just D.KeysOnly || (newprojtype == oldprojtype && newkeys `Set.isSubsetOf` oldkeys)+ newprojtype == Just D.PTKeysOnly || (newprojtype == oldprojtype && newkeys `Set.isSubsetOf` oldkeys) where newprojtype = newidx ^? D.gsiProjection . D.pProjectionType . _Just oldprojtype = oldidx ^? D.gsidProjection . _Just . D.pProjectionType . _Just@@ -115,7 +116,7 @@ keysOk newidx oldidx = Just (newidx ^. D.lsiKeySchema) == oldidx ^. D.lsidKeySchema -- Assume the indices were created by this module and we want them exactly the same projectionOk newidx oldidx =- newprojtype == Just D.KeysOnly || (newprojtype == oldprojtype && newkeys `Set.isSubsetOf` oldkeys)+ newprojtype == Just D.PTKeysOnly || (newprojtype == oldprojtype && newkeys `Set.isSubsetOf` oldkeys) where newprojtype = newidx ^? D.lsiProjection . D.pProjectionType . _Just oldprojtype = oldidx ^? D.lsidProjection . _Just . D.pProjectionType . _Just@@ -230,7 +231,7 @@ tblname = tblinfo ^. D.ctTableName tkeys = T.intercalate "," $ tblinfo ^.. (D.ctKeySchema . traverse . D.kseAttributeName) idxlist = tblinfo ^. D.ctGlobalSecondaryIndexes- indexinfo [] = ""+ indexinfo [] = "" indexinfo lst = " with indexes: " <> T.intercalate ", " (map printidx lst) printidx idx = idx ^. D.gsiIndexName <> "(" <> ikeys idx <> ")" ikeys idx = T.intercalate "," $ idx ^.. (D.gsiKeySchema . traverse . D.kseAttributeName)